1; RUN: opt -analyze -enable-new-pm=0 -scalar-evolution < %s | FileCheck %s 2; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s 3 4declare void @llvm.experimental.guard(i1, ...) 5declare void @llvm.assume(i1) 6 7define void @s_0(i32 %n, i1* %cond) { 8; CHECK-LABEL: Classifying expressions for: @s_0 9entry: 10 br label %loop 11 12loop: 13 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ] 14 %iv.inc = add i32 %iv, 1 15 %iv.sext = sext i32 %iv to i64 16; CHECK: %iv.sext = sext i32 %iv to i64 17; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> 18 %cmp = icmp slt i32 %iv, %n 19 call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ] 20 %c = load volatile i1, i1* %cond 21 br i1 %c, label %loop, label %leave 22 23leave: 24 ret void 25} 26 27define void @s_1(i1* %cond) { 28; CHECK-LABEL: Classifying expressions for: @s_1 29entry: 30 br label %loop 31 32loop: 33 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ] 34 %iv.inc = add i32 %iv, 3 35 %iv.sext = sext i32 %iv to i64 36; CHECK: %iv.sext = sext i32 %iv to i64 37; CHECK-NEXT: --> {0,+,3}<nuw><nsw><%loop> 38 %cmp = icmp slt i32 %iv, 10000 39 call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ] 40 %c = load volatile i1, i1* %cond 41 br i1 %c, label %loop, label %leave 42 43leave: 44 ret void 45} 46 47define void @s_2(i1* %cond) { 48; CHECK-LABEL: Classifying expressions for: @s_2 49entry: 50 br label %loop 51 52loop: 53 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ] 54 %iv.inc = add i32 %iv, 3 55 %iv.sext = sext i32 %iv to i64 56 %cmp = icmp slt i32 %iv, 10000 57; CHECK: %iv.sext = sext i32 %iv to i64 58; CHECK-NEXT: --> {0,+,3}<nuw><nsw><%loop> 59 call void @llvm.assume(i1 %cmp) 60 %c = load volatile i1, i1* %cond 61 br i1 %c, label %loop, label %leave 62 63leave: 64 ret void 65} 66 67define void @s_3(i32 %start, i1* %cond) { 68; CHECK-LABEL: Classifying expressions for: @s_3 69entry: 70 br label %loop 71 72loop: 73 %iv = phi i32 [ %start, %entry ], [ %iv.inc, %be ] 74 %cmp = icmp slt i32 %iv, 10000 75 br i1 %cmp, label %be, label %leave 76 77be: 78 %iv.inc = add i32 %iv, 3 79 %iv.inc.sext = sext i32 %iv.inc to i64 80; CHECK: %iv.inc.sext = sext i32 %iv.inc to i64 81; CHECK-NEXT: --> {(sext i32 (3 + %start) to i64),+,3}<nsw><%loop> 82 %c = load volatile i1, i1* %cond 83 br i1 %c, label %loop, label %leave 84 85leave: 86 ret void 87} 88 89define void @s_4(i32 %start, i1* %cond) { 90; CHECK-LABEL: Classifying expressions for: @s_4 91entry: 92 br label %loop 93 94loop: 95 %iv = phi i32 [ %start, %entry ], [ %iv.inc, %be ] 96 %cmp = icmp sgt i32 %iv, -1000 97 br i1 %cmp, label %be, label %leave 98 99be: 100 %iv.inc = add i32 %iv, -3 101 %iv.inc.sext = sext i32 %iv.inc to i64 102; CHECK: %iv.inc.sext = sext i32 %iv.inc to i64 103; CHECK-NEXT: --> {(sext i32 (-3 + %start) to i64),+,-3}<nsw><%loop> 104 %c = load volatile i1, i1* %cond 105 br i1 %c, label %loop, label %leave 106 107leave: 108 ret void 109} 110 111define void @u_0(i32 %n, i1* %cond) { 112; CHECK-LABEL: Classifying expressions for: @u_0 113entry: 114 br label %loop 115 116loop: 117 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ] 118 %iv.inc = add i32 %iv, 1 119 %iv.zext = zext i32 %iv to i64 120; CHECK: %iv.zext = zext i32 %iv to i64 121; CHECK-NEXT: --> {0,+,1}<nuw><%loop> 122 %cmp = icmp ult i32 %iv, %n 123 call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ] 124 %c = load volatile i1, i1* %cond 125 br i1 %c, label %loop, label %leave 126 127leave: 128 ret void 129} 130 131define void @u_1(i1* %cond) { 132; CHECK-LABEL: Classifying expressions for: @u_1 133entry: 134 br label %loop 135 136loop: 137 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ] 138 %iv.inc = add i32 %iv, 3 139 %iv.zext = zext i32 %iv to i64 140; CHECK: %iv.zext = zext i32 %iv to i64 141; CHECK-NEXT: --> {0,+,3}<nuw><%loop> 142 %cmp = icmp ult i32 %iv, 10000 143 call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ] 144 %c = load volatile i1, i1* %cond 145 br i1 %c, label %loop, label %leave 146 147leave: 148 ret void 149} 150 151define void @u_2(i1* %cond) { 152; CHECK-LABEL: Classifying expressions for: @u_2 153entry: 154 br label %loop 155 156loop: 157 %iv = phi i32 [ 30000, %entry ], [ %iv.inc, %loop ] 158 %iv.inc = add i32 %iv, -2 159 %iv.zext = zext i32 %iv to i64 160 %cmp = icmp ugt i32 %iv.inc, -10000 161; CHECK: %iv.zext = zext i32 %iv to i64 162; CHECK-NEXT: --> {30000,+,-2}<nw><%loop> 163 call void @llvm.assume(i1 %cmp) 164 %c = load volatile i1, i1* %cond 165 br i1 %c, label %loop, label %leave 166 167leave: 168 ret void 169} 170 171define void @u_3(i32 %start, i1* %cond) { 172; CHECK-LABEL: Classifying expressions for: @u_3 173entry: 174 br label %loop 175 176loop: 177 %iv = phi i32 [ %start, %entry ], [ %iv.inc, %be ] 178 %cmp = icmp ult i32 %iv, 10000 179 br i1 %cmp, label %be, label %leave 180 181be: 182 %iv.inc = add i32 %iv, 3 183 %iv.inc.zext = zext i32 %iv.inc to i64 184; CHECK: %iv.inc.zext = zext i32 %iv.inc to i64 185; CHECK-NEXT: --> {(zext i32 (3 + %start) to i64),+,3}<nuw><%loop> 186 %c = load volatile i1, i1* %cond 187 br i1 %c, label %loop, label %leave 188 189leave: 190 ret void 191} 192