blob: d0d2bbd67cf6b838ccfedc29930af51e33b2e412 [file] [log] [blame]
Dan Gohman211f53a2011-07-05 22:09:19 +00001; RUN: llc -asm-verbose=false -march=x86-64 -mtriple=x86_64-apple-darwin -o - < %s | FileCheck %s
Dan Gohmanc87b40b2010-06-04 19:16:34 +00002
Dan Gohman71997f32011-07-01 22:05:19 +00003; LSR should leave non-affine expressions alone because it currently
4; doesn't know how to do anything with them, and when it tries, it
5; gets SCEVExpander's current expansion for them, which is suboptimal.
Dan Gohmanc87b40b2010-06-04 19:16:34 +00006
Dan Gohman71997f32011-07-01 22:05:19 +00007; CHECK: xorl %eax, %eax
8; CHECK-NEXT: align
9; CHECK-NEXT: BB0_1:
Dan Gohman211f53a2011-07-05 22:09:19 +000010; CHECK-NEXT: movq %rax, (%rdx)
11; CHECK-NEXT: addq %rsi, %rax
12; CHECK-NEXT: cmpq %rdi, %rax
Dan Gohman71997f32011-07-01 22:05:19 +000013; CHECK-NEXT: jl
14; CHECK-NEXT: imulq %rax, %rax
15; CHECK-NEXT: ret
16define i64 @foo(i64 %n, i64 %s, i64* %p) nounwind {
17entry:
18 br label %loop
Dan Gohmanc87b40b2010-06-04 19:16:34 +000019
Dan Gohman71997f32011-07-01 22:05:19 +000020loop:
21 %i = phi i64 [ 0, %entry ], [ %i.next, %loop ]
22 volatile store i64 %i, i64* %p
23 %i.next = add i64 %i, %s
24 %c = icmp slt i64 %i.next, %n
25 br i1 %c, label %loop, label %exit
Dan Gohmanc87b40b2010-06-04 19:16:34 +000026
Dan Gohman71997f32011-07-01 22:05:19 +000027exit:
28 %mul = mul i64 %i.next, %i.next
29 ret i64 %mul
Dan Gohmanc87b40b2010-06-04 19:16:34 +000030}