1; RUN: opt < %s -indvars -S | FileCheck %s 2; PR4477 3; Indvars should compute the exit values in loop. 4; 5; XFAIL: * 6; Indvars does not currently replace loop invariant values unless all 7; loop exits have the same exit value. We could handle some cases, 8; such as this, by making getSCEVAtScope() sensitive to a particular 9; loop exit. See PR11388. 10 11target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" 12target triple = "i386-pc-linux-gnu" 13 %struct.cc70a02__complex_integers__complex_type = type { i8, i8 } 14@.str = internal constant [13 x i8] c"fc70a00.adb\00\00", align 1 ; <[13 x i8]*> [#uses=1] 15 16define void @_ada_cc70a02() { 17; CHECK-LABEL: @_ada_cc70a02( 18; CHECK: [%]tmp7 = icmp eq i8 -28, -28 19; CHECK: [%]tmp8 = icmp eq i8 63, 63 20 21entry: 22 br label %bb1.i 23 24bb1.i: ; preds = %bb2.i, %entry 25 %indvar.i = phi i32 [ 0, %entry ], [ %indvar.next.i, %bb2.i ] ; <i32> [#uses=2] 26 %result.0.i = phi i16 [ 0, %entry ], [ %ins36.i, %bb2.i ] ; <i16> [#uses=2] 27 %tmp38.i = trunc i16 %result.0.i to i8 ; <i8> [#uses=2] 28 %tmp = add i8 %tmp38.i, 96 ; <i8> [#uses=1] 29 %tmp1 = icmp ugt i8 %tmp, -56 ; <i1> [#uses=1] 30 br i1 %tmp1, label %bb.i.i, label %bb1.i.i 31 32bb.i.i: ; preds = %bb1.i 33 tail call void @__gnat_rcheck_12(i8* getelementptr ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), i32 24) noreturn 34 unreachable 35 36bb1.i.i: ; preds = %bb1.i 37 %tmp41.i = lshr i16 %result.0.i, 8 ; <i16> [#uses=1] 38 %tmp42.i = trunc i16 %tmp41.i to i8 ; <i8> [#uses=2] 39 %tmp2 = add i8 %tmp42.i, 109 ; <i8> [#uses=1] 40 %tmp3 = icmp ugt i8 %tmp2, -56 ; <i1> [#uses=1] 41 br i1 %tmp3, label %bb2.i.i, label %cc70a02__complex_integers__Oadd.153.exit.i 42 43bb2.i.i: ; preds = %bb1.i.i 44 tail call void @__gnat_rcheck_12(i8* getelementptr ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), i32 24) noreturn 45 unreachable 46 47cc70a02__complex_integers__Oadd.153.exit.i: ; preds = %bb1.i.i 48 %tmp4 = add i8 %tmp38.i, -4 ; <i8> [#uses=2] 49 %tmp5 = add i8 %tmp42.i, 9 ; <i8> [#uses=2] 50 %tmp25.i = zext i8 %tmp4 to i16 ; <i16> [#uses=1] 51 %tmp33.i = zext i8 %tmp5 to i16 ; <i16> [#uses=1] 52 %tmp34.i = shl i16 %tmp33.i, 8 ; <i16> [#uses=1] 53 %ins36.i = or i16 %tmp34.i, %tmp25.i ; <i16> [#uses=1] 54 %tmp6 = icmp eq i32 %indvar.i, 6 ; <i1> [#uses=1] 55 br i1 %tmp6, label %cc70a02__complex_multiplication.170.exit, label %bb2.i 56 57bb2.i: ; preds = %cc70a02__complex_integers__Oadd.153.exit.i 58 %indvar.next.i = add i32 %indvar.i, 1 ; <i32> [#uses=1] 59 br label %bb1.i 60 61cc70a02__complex_multiplication.170.exit: ; preds = %cc70a02__complex_integers__Oadd.153.exit.i 62 %tmp7 = icmp eq i8 %tmp4, -28 ; <i1> [#uses=1] 63 %tmp8 = icmp eq i8 %tmp5, 63 ; <i1> [#uses=1] 64 %or.cond = and i1 %tmp8, %tmp7 ; <i1> [#uses=1] 65 br i1 %or.cond, label %return, label %bb1 66 67bb1: ; preds = %cc70a02__complex_multiplication.170.exit 68 tail call void @exit(i32 1) 69 ret void 70 71return: ; preds = %cc70a02__complex_multiplication.170.exit 72 ret void 73} 74 75declare fastcc void @cc70a02__complex_integers__complex.164(%struct.cc70a02__complex_integers__complex_type* noalias nocapture sret(%struct.cc70a02__complex_integers__complex_type), i8 signext, i8 signext) nounwind 76 77declare fastcc void @cc70a02__complex_integers__Osubtract.149(%struct.cc70a02__complex_integers__complex_type* noalias sret(%struct.cc70a02__complex_integers__complex_type), %struct.cc70a02__complex_integers__complex_type* byval(%struct.cc70a02__complex_integers__complex_type) align 4) 78 79declare fastcc void @cc70a02__complex_integers__Oadd.153(%struct.cc70a02__complex_integers__complex_type* noalias sret(%struct.cc70a02__complex_integers__complex_type), %struct.cc70a02__complex_integers__complex_type* byval(%struct.cc70a02__complex_integers__complex_type) align 4, %struct.cc70a02__complex_integers__complex_type* byval(%struct.cc70a02__complex_integers__complex_type) align 4) 80 81declare fastcc void @cc70a02__complex_multiplication.170(%struct.cc70a02__complex_integers__complex_type* noalias sret(%struct.cc70a02__complex_integers__complex_type), %struct.cc70a02__complex_integers__complex_type* byval(%struct.cc70a02__complex_integers__complex_type) align 4) 82 83declare void @__gnat_rcheck_12(i8*, i32) noreturn 84 85declare void @exit(i32) 86