1 ; RUN: llc < %s -mtriple=thumbv7-apple-darwin10 -relocation-model=pic | FileCheck %s 2 ; rdar://7387640 3 4 ; This now reduces to a single induction variable. 5 6 @G = external global i32 ; <i32*> [#uses=2] 7 @array = external global i32* ; <i32**> [#uses=1] 8 9 define void @t() nounwind optsize { 10 ; CHECK-LABEL: t: 11 ; CHECK: mov{{.*}}, #1000 12 entry: 13 %.pre = load i32, i32* @G, align 4 ; <i32> [#uses=1] 14 br label %bb 15 16 bb: ; preds = %bb, %entry 17 ; CHECK: LBB0_1: 18 ; CHECK: subs [[R2:r[0-9]+]], #1 19 ; CHECK: cmp.w [[R2]], #-1 20 ; CHECK: bne LBB0_1 21 22 %0 = phi i32 [ %.pre, %entry ], [ %3, %bb ] ; <i32> [#uses=1] 23 %indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb ] ; <i32> [#uses=2] 24 %tmp5 = sub i32 1000, %indvar ; <i32> [#uses=1] 25 %1 = load i32*, i32** @array, align 4 ; <i32*> [#uses=1] 26 %scevgep = getelementptr i32, i32* %1, i32 %tmp5 ; <i32*> [#uses=1] 27 %2 = load i32, i32* %scevgep, align 4 ; <i32> [#uses=1] 28 %3 = add nsw i32 %2, %0 ; <i32> [#uses=2] 29 store i32 %3, i32* @G, align 4 30 %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=2] 31 %exitcond = icmp eq i32 %indvar.next, 1001 ; <i1> [#uses=1] 32 br i1 %exitcond, label %return, label %bb 33 34 return: ; preds = %bb 35 ret void 36 } 37