Evan Cheng | 586f69a | 2009-11-12 07:35:05 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -mtriple=thumbv7-apple-darwin10 -relocation-model=pic | FileCheck %s |
| 2 | ; rdar://7387640 |
| 3 | |
Dan Gohman | 572645c | 2010-02-12 10:34:29 +0000 | [diff] [blame] | 4 | ; This now reduces to a single induction variable. |
| 5 | |
| 6 | ; TODO: It still gets a GPR shuffle at the end of the loop |
| 7 | ; This is because something in instruction selection has decided |
| 8 | ; that comparing the pre-incremented value with zero is better |
| 9 | ; than comparing the post-incremented value with -4. |
Evan Cheng | 586f69a | 2009-11-12 07:35:05 +0000 | [diff] [blame] | 10 | |
| 11 | @G = external global i32 ; <i32*> [#uses=2] |
| 12 | @array = external global i32* ; <i32**> [#uses=1] |
| 13 | |
Rafael Espindola | 1e81966 | 2010-06-17 15:18:27 +0000 | [diff] [blame^] | 14 | define void @t() nounwind optsize { |
Evan Cheng | 586f69a | 2009-11-12 07:35:05 +0000 | [diff] [blame] | 15 | ; CHECK: t: |
Dan Gohman | 572645c | 2010-02-12 10:34:29 +0000 | [diff] [blame] | 16 | ; CHECK: mov.w r2, #1000 |
Evan Cheng | 586f69a | 2009-11-12 07:35:05 +0000 | [diff] [blame] | 17 | entry: |
| 18 | %.pre = load i32* @G, align 4 ; <i32> [#uses=1] |
| 19 | br label %bb |
| 20 | |
| 21 | bb: ; preds = %bb, %entry |
Dan Gohman | 9f23dee | 2010-04-17 16:29:15 +0000 | [diff] [blame] | 22 | ; CHECK: LBB0_1: |
Dan Gohman | 572645c | 2010-02-12 10:34:29 +0000 | [diff] [blame] | 23 | ; CHECK: cmp r2, #0 |
| 24 | ; CHECK: sub.w r9, r2, #1 |
| 25 | ; CHECK: mov r2, r9 |
| 26 | |
Evan Cheng | 586f69a | 2009-11-12 07:35:05 +0000 | [diff] [blame] | 27 | %0 = phi i32 [ %.pre, %entry ], [ %3, %bb ] ; <i32> [#uses=1] |
| 28 | %indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb ] ; <i32> [#uses=2] |
| 29 | %tmp5 = sub i32 1000, %indvar ; <i32> [#uses=1] |
| 30 | %1 = load i32** @array, align 4 ; <i32*> [#uses=1] |
| 31 | %scevgep = getelementptr i32* %1, i32 %tmp5 ; <i32*> [#uses=1] |
| 32 | %2 = load i32* %scevgep, align 4 ; <i32> [#uses=1] |
| 33 | %3 = add nsw i32 %2, %0 ; <i32> [#uses=2] |
| 34 | store i32 %3, i32* @G, align 4 |
| 35 | %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=2] |
| 36 | %exitcond = icmp eq i32 %indvar.next, 1001 ; <i1> [#uses=1] |
| 37 | br i1 %exitcond, label %return, label %bb |
| 38 | |
| 39 | return: ; preds = %bb |
| 40 | ret void |
| 41 | } |