-; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis &&
-
; Base should not be i*3, it should be i*2.
-; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | not grep 'mul.*%i, 3' &&
+; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | \
+; RUN: not grep {mul.*%i, 3}
; Indvar should not start at zero:
-; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | not grep 'phi uint .* 0'
+; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | \
+; RUN: not grep {phi i32 .* 0}
+; END.
; mul uint %i, 3
-; ModuleID = 't.bc'
target datalayout = "e-p:32:32"
-target endian = little
-target pointersize = 32
target triple = "i686-apple-darwin8"
-%flags2 = external global [8193 x sbyte], align 32 ; <[8193 x sbyte]*> [#uses=1]
-
-implementation ; Functions:
+@flags2 = external global [8193 x i8], align 32 ; <[8193 x i8]*> [#uses=1]
-void %foo(int %k, int %i) {
+define void @foo(i32 %k, i32 %i.s) {
entry:
- %i = cast int %i to uint ; <uint> [#uses=2]
- %k_addr.012 = shl int %i, ubyte 1 ; <int> [#uses=1]
- %tmp14 = setgt int %k_addr.012, 8192 ; <bool> [#uses=1]
- br bool %tmp14, label %return, label %bb.preheader
-
+ %i = bitcast i32 %i.s to i32 ; <i32> [#uses=2]
+ %k_addr.012 = shl i32 %i.s, 1 ; <i32> [#uses=1]
+ %tmp14 = icmp sgt i32 %k_addr.012, 8192 ; <i1> [#uses=1]
+ br i1 %tmp14, label %return, label %bb.preheader
bb.preheader: ; preds = %entry
- %tmp. = shl uint %i, ubyte 1 ; <uint> [#uses=1]
+ %tmp. = shl i32 %i, 1 ; <i32> [#uses=1]
br label %bb
-
bb: ; preds = %bb, %bb.preheader
- %indvar = phi uint [ %indvar.next, %bb ], [ 0, %bb.preheader ] ; <uint> [#uses=2]
- %tmp.15 = mul uint %indvar, %i ; <uint> [#uses=1]
- %tmp.16 = add uint %tmp.15, %tmp. ; <uint> [#uses=2]
- %k_addr.0.0 = cast uint %tmp.16 to int ; <int> [#uses=1]
- %tmp = getelementptr [8193 x sbyte]* %flags2, int 0, uint %tmp.16 ; <sbyte*> [#uses=1]
- store sbyte 0, sbyte* %tmp
- %k_addr.0 = add int %k_addr.0.0, %i ; <int> [#uses=1]
- %tmp = setgt int %k_addr.0, 8192 ; <bool> [#uses=1]
- %indvar.next = add uint %indvar, 1 ; <uint> [#uses=1]
- br bool %tmp, label %return.loopexit, label %bb
-
+ %indvar = phi i32 [ %indvar.next, %bb ], [ 0, %bb.preheader ] ; <i32> [#uses=2]
+ %tmp.15 = mul i32 %indvar, %i ; <i32> [#uses=1]
+ %tmp.16 = add i32 %tmp.15, %tmp. ; <i32> [#uses=2]
+ %k_addr.0.0 = bitcast i32 %tmp.16 to i32 ; <i32> [#uses=1]
+ %gep.upgrd.1 = zext i32 %tmp.16 to i64 ; <i64> [#uses=1]
+ %tmp = getelementptr [8193 x i8]* @flags2, i32 0, i64 %gep.upgrd.1 ; <i8*> [#uses=1]
+ store i8 0, i8* %tmp
+ %k_addr.0 = add i32 %k_addr.0.0, %i.s ; <i32> [#uses=1]
+ %tmp.upgrd.2 = icmp sgt i32 %k_addr.0, 8192 ; <i1> [#uses=1]
+ %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
+ br i1 %tmp.upgrd.2, label %return.loopexit, label %bb
return.loopexit: ; preds = %bb
br label %return
-
return: ; preds = %return.loopexit, %entry
ret void
}