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