1 ; RUN: opt < %s -indvars -S > %t 2 ; RUN: not grep sext %t 3 4 define i64 @test(i64* nocapture %first, i32 %count) nounwind readonly { 5 entry: 6 %t0 = icmp sgt i32 %count, 0 ; <i1> [#uses=1] 7 br i1 %t0, label %bb.nph, label %bb2 8 9 bb.nph: ; preds = %entry 10 br label %bb 11 12 bb: ; preds = %bb1, %bb.nph 13 %result.02 = phi i64 [ %t5, %bb1 ], [ 0, %bb.nph ] ; <i64> [#uses=1] 14 %n.01 = phi i32 [ %t6, %bb1 ], [ 0, %bb.nph ] ; <i32> [#uses=2] 15 %t1 = sext i32 %n.01 to i64 ; <i64> [#uses=1] 16 %t2 = getelementptr i64* %first, i64 %t1 ; <i64*> [#uses=1] 17 %t3 = load i64* %t2, align 8 ; <i64> [#uses=1] 18 %t4 = lshr i64 %t3, 4 ; <i64> [#uses=1] 19 %t5 = add i64 %t4, %result.02 ; <i64> [#uses=2] 20 %t6 = add i32 %n.01, 1 ; <i32> [#uses=2] 21 br label %bb1 22 23 bb1: ; preds = %bb 24 %t7 = icmp slt i32 %t6, %count ; <i1> [#uses=1] 25 br i1 %t7, label %bb, label %bb1.bb2_crit_edge 26 27 bb1.bb2_crit_edge: ; preds = %bb1 28 %.lcssa = phi i64 [ %t5, %bb1 ] ; <i64> [#uses=1] 29 br label %bb2 30 31 bb2: ; preds = %bb1.bb2_crit_edge, %entry 32 %result.0.lcssa = phi i64 [ %.lcssa, %bb1.bb2_crit_edge ], [ 0, %entry ] ; <i64> [#uses=1] 33 ret i64 %result.0.lcssa 34 } 35 36 define void @foo(i16 signext %N, i32* nocapture %P) nounwind { 37 entry: 38 %t0 = icmp sgt i16 %N, 0 ; <i1> [#uses=1] 39 br i1 %t0, label %bb.nph, label %return 40 41 bb.nph: ; preds = %entry 42 br label %bb 43 44 bb: ; preds = %bb1, %bb.nph 45 %i.01 = phi i16 [ %t3, %bb1 ], [ 0, %bb.nph ] ; <i16> [#uses=2] 46 %t1 = sext i16 %i.01 to i64 ; <i64> [#uses=1] 47 %t2 = getelementptr i32* %P, i64 %t1 ; <i32*> [#uses=1] 48 store i32 123, i32* %t2, align 4 49 %t3 = add i16 %i.01, 1 ; <i16> [#uses=2] 50 br label %bb1 51 52 bb1: ; preds = %bb 53 %t4 = icmp slt i16 %t3, %N ; <i1> [#uses=1] 54 br i1 %t4, label %bb, label %bb1.return_crit_edge 55 56 bb1.return_crit_edge: ; preds = %bb1 57 br label %return 58 59 return: ; preds = %bb1.return_crit_edge, %entry 60 ret void 61 } 62 63 ; Test cases from PR1301: 64 65 define void @kinds__srangezero([21 x i32]* nocapture %a) nounwind { 66 bb.thread: 67 br label %bb 68 69 bb: ; preds = %bb, %bb.thread 70 %i.0.reg2mem.0 = phi i8 [ -10, %bb.thread ], [ %tmp7, %bb ] ; <i8> [#uses=2] 71 %tmp12 = sext i8 %i.0.reg2mem.0 to i32 ; <i32> [#uses=1] 72 %tmp4 = add i32 %tmp12, 10 ; <i32> [#uses=1] 73 %tmp5 = getelementptr [21 x i32]* %a, i32 0, i32 %tmp4 ; <i32*> [#uses=1] 74 store i32 0, i32* %tmp5 75 %tmp7 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=2] 76 %0 = icmp sgt i8 %tmp7, 10 ; <i1> [#uses=1] 77 br i1 %0, label %return, label %bb 78 79 return: ; preds = %bb 80 ret void 81 } 82 83 define void @kinds__urangezero([21 x i32]* nocapture %a) nounwind { 84 bb.thread: 85 br label %bb 86 87 bb: ; preds = %bb, %bb.thread 88 %i.0.reg2mem.0 = phi i8 [ 10, %bb.thread ], [ %tmp7, %bb ] ; <i8> [#uses=2] 89 %tmp12 = sext i8 %i.0.reg2mem.0 to i32 ; <i32> [#uses=1] 90 %tmp4 = add i32 %tmp12, -10 ; <i32> [#uses=1] 91 %tmp5 = getelementptr [21 x i32]* %a, i32 0, i32 %tmp4 ; <i32*> [#uses=1] 92 store i32 0, i32* %tmp5 93 %tmp7 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=2] 94 %0 = icmp sgt i8 %tmp7, 30 ; <i1> [#uses=1] 95 br i1 %0, label %return, label %bb 96 97 return: ; preds = %bb 98 ret void 99 } 100