1 ; RUN: llc < %s -mtriple=i686-apple-darwin -relocation-model=static | FileCheck %s -check-prefix=STATIC 2 ; RUN: llc < %s -mtriple=i686-apple-darwin -relocation-model=pic | FileCheck %s -check-prefix=PIC 3 4 ; By starting the IV at -64 instead of 0, a cmp is eliminated, 5 ; as the flags from the add can be used directly. 6 7 ; STATIC: movl $-64, [[ECX:%e..]] 8 9 ; STATIC: movl [[EAX:%e..]], _state+76([[ECX]]) 10 ; STATIC: addl $16, [[ECX]] 11 ; STATIC: jne 12 13 ; In PIC mode the symbol can't be folded, so the change-compare-stride 14 ; trick applies. 15 16 ; PIC: cmpl $64 17 18 @state = external global [0 x i32] ; <[0 x i32]*> [#uses=4] 19 @S = external global [0 x i32] ; <[0 x i32]*> [#uses=4] 20 21 define i32 @foo() nounwind { 22 entry: 23 br label %bb 24 25 bb: ; preds = %bb, %entry 26 %indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb ] ; <i32> [#uses=2] 27 %t.063.0 = phi i32 [ 0, %entry ], [ %tmp47, %bb ] ; <i32> [#uses=1] 28 %j.065.0 = shl i32 %indvar, 2 ; <i32> [#uses=4] 29 %tmp3 = getelementptr [0 x i32]* @state, i32 0, i32 %j.065.0 ; <i32*> [#uses=2] 30 %tmp4 = load i32* %tmp3, align 4 ; <i32> [#uses=1] 31 %tmp6 = getelementptr [0 x i32]* @S, i32 0, i32 %t.063.0 ; <i32*> [#uses=1] 32 %tmp7 = load i32* %tmp6, align 4 ; <i32> [#uses=1] 33 %tmp8 = xor i32 %tmp7, %tmp4 ; <i32> [#uses=2] 34 store i32 %tmp8, i32* %tmp3, align 4 35 %tmp1378 = or i32 %j.065.0, 1 ; <i32> [#uses=1] 36 %tmp16 = getelementptr [0 x i32]* @state, i32 0, i32 %tmp1378 ; <i32*> [#uses=2] 37 %tmp17 = load i32* %tmp16, align 4 ; <i32> [#uses=1] 38 %tmp19 = getelementptr [0 x i32]* @S, i32 0, i32 %tmp8 ; <i32*> [#uses=1] 39 %tmp20 = load i32* %tmp19, align 4 ; <i32> [#uses=1] 40 %tmp21 = xor i32 %tmp20, %tmp17 ; <i32> [#uses=2] 41 store i32 %tmp21, i32* %tmp16, align 4 42 %tmp2680 = or i32 %j.065.0, 2 ; <i32> [#uses=1] 43 %tmp29 = getelementptr [0 x i32]* @state, i32 0, i32 %tmp2680 ; <i32*> [#uses=2] 44 %tmp30 = load i32* %tmp29, align 4 ; <i32> [#uses=1] 45 %tmp32 = getelementptr [0 x i32]* @S, i32 0, i32 %tmp21 ; <i32*> [#uses=1] 46 %tmp33 = load i32* %tmp32, align 4 ; <i32> [#uses=1] 47 %tmp34 = xor i32 %tmp33, %tmp30 ; <i32> [#uses=2] 48 store i32 %tmp34, i32* %tmp29, align 4 49 %tmp3982 = or i32 %j.065.0, 3 ; <i32> [#uses=1] 50 %tmp42 = getelementptr [0 x i32]* @state, i32 0, i32 %tmp3982 ; <i32*> [#uses=2] 51 %tmp43 = load i32* %tmp42, align 4 ; <i32> [#uses=1] 52 %tmp45 = getelementptr [0 x i32]* @S, i32 0, i32 %tmp34 ; <i32*> [#uses=1] 53 %tmp46 = load i32* %tmp45, align 4 ; <i32> [#uses=1] 54 %tmp47 = xor i32 %tmp46, %tmp43 ; <i32> [#uses=3] 55 store i32 %tmp47, i32* %tmp42, align 4 56 %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=2] 57 %exitcond = icmp eq i32 %indvar.next, 4 ; <i1> [#uses=1] 58 br i1 %exitcond, label %bb57, label %bb 59 60 bb57: ; preds = %bb 61 %tmp59 = and i32 %tmp47, 255 ; <i32> [#uses=1] 62 ret i32 %tmp59 63 } 64