Dan Gohman | 211f53a | 2011-07-05 22:09:19 +0000 | [diff] [blame] | 1 | ; RUN: llc -asm-verbose=false -march=x86-64 -mtriple=x86_64-apple-darwin -o - < %s | FileCheck %s |
Dan Gohman | c87b40b | 2010-06-04 19:16:34 +0000 | [diff] [blame] | 2 | |
Dan Gohman | 71997f3 | 2011-07-01 22:05:19 +0000 | [diff] [blame] | 3 | ; 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 Gohman | c87b40b | 2010-06-04 19:16:34 +0000 | [diff] [blame] | 6 | |
Dan Gohman | 71997f3 | 2011-07-01 22:05:19 +0000 | [diff] [blame] | 7 | ; CHECK: xorl %eax, %eax |
| 8 | ; CHECK-NEXT: align |
| 9 | ; CHECK-NEXT: BB0_1: |
Dan Gohman | 211f53a | 2011-07-05 22:09:19 +0000 | [diff] [blame] | 10 | ; CHECK-NEXT: movq %rax, (%rdx) |
| 11 | ; CHECK-NEXT: addq %rsi, %rax |
| 12 | ; CHECK-NEXT: cmpq %rdi, %rax |
Dan Gohman | 71997f3 | 2011-07-01 22:05:19 +0000 | [diff] [blame] | 13 | ; CHECK-NEXT: jl |
| 14 | ; CHECK-NEXT: imulq %rax, %rax |
| 15 | ; CHECK-NEXT: ret |
| 16 | define i64 @foo(i64 %n, i64 %s, i64* %p) nounwind { |
| 17 | entry: |
| 18 | br label %loop |
Dan Gohman | c87b40b | 2010-06-04 19:16:34 +0000 | [diff] [blame] | 19 | |
Dan Gohman | 71997f3 | 2011-07-01 22:05:19 +0000 | [diff] [blame] | 20 | loop: |
| 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 Gohman | c87b40b | 2010-06-04 19:16:34 +0000 | [diff] [blame] | 26 | |
Dan Gohman | 71997f3 | 2011-07-01 22:05:19 +0000 | [diff] [blame] | 27 | exit: |
| 28 | %mul = mul i64 %i.next, %i.next |
| 29 | ret i64 %mul |
Dan Gohman | c87b40b | 2010-06-04 19:16:34 +0000 | [diff] [blame] | 30 | } |