289 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py2; RUN: opt -passes='print<scalar-evolution>' -disable-output %s 2>&1 | FileCheck %s3 4define void @test_multiple_const_guards_order1(ptr nocapture %a, i64 %i) {5; CHECK-LABEL: 'test_multiple_const_guards_order1'6; CHECK-NEXT: Classifying expressions for: @test_multiple_const_guards_order17; CHECK-NEXT: %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]8; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,10) S: [0,10) Exits: %i LoopDispositions: { %loop: Computable }9; CHECK-NEXT: %idx = getelementptr inbounds i32, ptr %a, i64 %iv10; CHECK-NEXT: --> {%a,+,4}<nuw><%loop> U: full-set S: full-set Exits: ((4 * %i) + %a) LoopDispositions: { %loop: Computable }11; CHECK-NEXT: %iv.next = add nuw nsw i64 %iv, 112; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,11) S: [1,11) Exits: (1 + %i) LoopDispositions: { %loop: Computable }13; CHECK-NEXT: Determining loop execution counts for: @test_multiple_const_guards_order114; CHECK-NEXT: Loop %loop: backedge-taken count is %i15; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 916; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is %i17; CHECK-NEXT: Loop %loop: Trip multiple is 118;19entry:20 %c.1 = icmp ult i64 %i, 1621 br i1 %c.1, label %guardbb, label %exit22 23guardbb:24 %c.2 = icmp ult i64 %i, 1025 br i1 %c.2, label %loop, label %exit26 27loop:28 %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]29 %idx = getelementptr inbounds i32, ptr %a, i64 %iv30 store i32 1, ptr %idx, align 431 %iv.next = add nuw nsw i64 %iv, 132 %exitcond = icmp eq i64 %iv, %i33 br i1 %exitcond, label %exit, label %loop34 35exit:36 ret void37}38 39define void @test_multiple_const_guards_order2(ptr nocapture %a, i64 %i) {40; CHECK-LABEL: 'test_multiple_const_guards_order2'41; CHECK-NEXT: Classifying expressions for: @test_multiple_const_guards_order242; CHECK-NEXT: %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]43; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,10) S: [0,10) Exits: %i LoopDispositions: { %loop: Computable }44; CHECK-NEXT: %idx = getelementptr inbounds i32, ptr %a, i64 %iv45; CHECK-NEXT: --> {%a,+,4}<nuw><%loop> U: full-set S: full-set Exits: ((4 * %i) + %a) LoopDispositions: { %loop: Computable }46; CHECK-NEXT: %iv.next = add nuw nsw i64 %iv, 147; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,11) S: [1,11) Exits: (1 + %i) LoopDispositions: { %loop: Computable }48; CHECK-NEXT: Determining loop execution counts for: @test_multiple_const_guards_order249; CHECK-NEXT: Loop %loop: backedge-taken count is %i50; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 951; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is %i52; CHECK-NEXT: Loop %loop: Trip multiple is 153;54entry:55 %c.1 = icmp ult i64 %i, 1056 br i1 %c.1, label %guardbb, label %exit57 58guardbb:59 %c.2 = icmp ult i64 %i, 1660 br i1 %c.2, label %loop, label %exit61 62loop:63 %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]64 %idx = getelementptr inbounds i32, ptr %a, i64 %iv65 store i32 1, ptr %idx, align 466 %iv.next = add nuw nsw i64 %iv, 167 %exitcond = icmp eq i64 %iv, %i68 br i1 %exitcond, label %exit, label %loop69 70exit:71 ret void72}73 74define void @test_multiple_var_guards_order1(ptr nocapture %a, i64 %i, i64 %N) {75; CHECK-LABEL: 'test_multiple_var_guards_order1'76; CHECK-NEXT: Classifying expressions for: @test_multiple_var_guards_order177; CHECK-NEXT: %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]78; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,11) S: [0,11) Exits: %i LoopDispositions: { %loop: Computable }79; CHECK-NEXT: %idx = getelementptr inbounds i32, ptr %a, i64 %iv80; CHECK-NEXT: --> {%a,+,4}<nuw><%loop> U: full-set S: full-set Exits: ((4 * %i) + %a) LoopDispositions: { %loop: Computable }81; CHECK-NEXT: %iv.next = add nuw nsw i64 %iv, 182; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,12) S: [1,12) Exits: (1 + %i) LoopDispositions: { %loop: Computable }83; CHECK-NEXT: Determining loop execution counts for: @test_multiple_var_guards_order184; CHECK-NEXT: Loop %loop: backedge-taken count is %i85; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 1086; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is %i87; CHECK-NEXT: Loop %loop: Trip multiple is 188;89entry:90 %c.1 = icmp ult i64 %N, 1291 br i1 %c.1, label %guardbb, label %exit92 93guardbb:94 %c.2 = icmp ult i64 %i, %N95 br i1 %c.2, label %loop, label %exit96 97loop:98 %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]99 %idx = getelementptr inbounds i32, ptr %a, i64 %iv100 store i32 1, ptr %idx, align 4101 %iv.next = add nuw nsw i64 %iv, 1102 %exitcond = icmp eq i64 %iv, %i103 br i1 %exitcond, label %exit, label %loop104 105exit:106 ret void107}108 109define void @test_multiple_var_guards_order2(ptr nocapture %a, i64 %i, i64 %N) {110; CHECK-LABEL: 'test_multiple_var_guards_order2'111; CHECK-NEXT: Classifying expressions for: @test_multiple_var_guards_order2112; CHECK-NEXT: %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]113; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,11) S: [0,11) Exits: %i LoopDispositions: { %loop: Computable }114; CHECK-NEXT: %idx = getelementptr inbounds i32, ptr %a, i64 %iv115; CHECK-NEXT: --> {%a,+,4}<nuw><%loop> U: full-set S: full-set Exits: ((4 * %i) + %a) LoopDispositions: { %loop: Computable }116; CHECK-NEXT: %iv.next = add nuw nsw i64 %iv, 1117; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,12) S: [1,12) Exits: (1 + %i) LoopDispositions: { %loop: Computable }118; CHECK-NEXT: Determining loop execution counts for: @test_multiple_var_guards_order2119; CHECK-NEXT: Loop %loop: backedge-taken count is %i120; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 10121; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is %i122; CHECK-NEXT: Loop %loop: Trip multiple is 1123;124entry:125 %c.1 = icmp ult i64 %i, %N126 br i1 %c.1, label %guardbb, label %exit127 128guardbb:129 %c.2 = icmp ult i64 %N, 12130 br i1 %c.2, label %loop, label %exit131 132loop:133 %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]134 %idx = getelementptr inbounds i32, ptr %a, i64 %iv135 store i32 1, ptr %idx, align 4136 %iv.next = add nuw nsw i64 %iv, 1137 %exitcond = icmp eq i64 %iv, %i138 br i1 %exitcond, label %exit, label %loop139 140exit:141 ret void142}143 144define i32 @sle_sgt_ult_umax_to_smax(i32 %num) {145; CHECK-LABEL: 'sle_sgt_ult_umax_to_smax'146; CHECK-NEXT: Classifying expressions for: @sle_sgt_ult_umax_to_smax147; CHECK-NEXT: %iv = phi i32 [ 0, %guard.3 ], [ %iv.next, %loop ]148; CHECK-NEXT: --> {0,+,4}<nuw><nsw><%loop> U: [0,25) S: [0,25) Exits: (4 * ((-4 + %num) /u 4))<nuw> LoopDispositions: { %loop: Computable }149; CHECK-NEXT: %iv.next = add nuw i32 %iv, 4150; CHECK-NEXT: --> {4,+,4}<nuw><nsw><%loop> U: [4,29) S: [4,29) Exits: (4 + (4 * ((-4 + %num) /u 4))<nuw>) LoopDispositions: { %loop: Computable }151; CHECK-NEXT: Determining loop execution counts for: @sle_sgt_ult_umax_to_smax152; CHECK-NEXT: Loop %loop: backedge-taken count is ((-4 + %num) /u 4)153; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 6154; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-4 + %num) /u 4)155; CHECK-NEXT: Loop %loop: Trip multiple is 1156;157guard.1:158 %cmp.1 = icmp sle i32 %num, 0159 br i1 %cmp.1, label %exit, label %guard.2160 161guard.2:162 %cmp.2 = icmp sgt i32 %num, 28163 br i1 %cmp.2, label %exit, label %guard.3164 165guard.3:166 %cmp.3 = icmp ult i32 %num, 4167 br i1 %cmp.3, label %exit, label %loop168 169loop:170 %iv = phi i32 [ 0, %guard.3 ], [ %iv.next, %loop ]171 %iv.next = add nuw i32 %iv, 4172 %ec = icmp eq i32 %iv.next, %num173 br i1 %ec, label %exit, label %loop174 175exit:176 ret i32 0177}178 179; Similar to @sle_sgt_ult_umax_to_smax but with different predicate order.180define i32 @ult_sle_sgt_umax_to_smax(i32 %num) {181; CHECK-LABEL: 'ult_sle_sgt_umax_to_smax'182; CHECK-NEXT: Classifying expressions for: @ult_sle_sgt_umax_to_smax183; CHECK-NEXT: %iv = phi i32 [ 0, %guard.3 ], [ %iv.next, %loop ]184; CHECK-NEXT: --> {0,+,4}<nuw><%loop> U: [0,-3) S: [-2147483648,2147483645) Exits: (4 * ((-4 + %num) /u 4))<nuw> LoopDispositions: { %loop: Computable }185; CHECK-NEXT: %iv.next = add nuw i32 %iv, 4186; CHECK-NEXT: --> {4,+,4}<nuw><%loop> U: [4,-3) S: [-2147483648,2147483645) Exits: (4 + (4 * ((-4 + %num) /u 4))<nuw>) LoopDispositions: { %loop: Computable }187; CHECK-NEXT: Determining loop execution counts for: @ult_sle_sgt_umax_to_smax188; CHECK-NEXT: Loop %loop: backedge-taken count is ((-4 + %num) /u 4)189; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 1073741823190; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-4 + %num) /u 4)191; CHECK-NEXT: Loop %loop: Trip multiple is 1192;193guard.1:194 %cmp.1 = icmp ult i32 %num, 4195 br i1 %cmp.1, label %exit, label %guard.2196 197guard.2:198 %cmp.2 = icmp sgt i32 %num, 28199 br i1 %cmp.2, label %exit, label %guard.3200 201guard.3:202 %cmp.3 = icmp sle i32 %num, 0203 br i1 %cmp.3, label %exit, label %loop204 205loop:206 %iv = phi i32 [ 0, %guard.3 ], [ %iv.next, %loop ]207 %iv.next = add nuw i32 %iv, 4208 %ec = icmp eq i32 %iv.next, %num209 br i1 %ec, label %exit, label %loop210 211exit:212 ret i32 0213}214 215define void @const_max_btc_32_or_order_1(i64 %n) {216; CHECK-LABEL: 'const_max_btc_32_or_order_1'217; CHECK-NEXT: Classifying expressions for: @const_max_btc_32_or_order_1218; CHECK-NEXT: %and.pre = and i1 %pre.1, %pre.0219; CHECK-NEXT: --> (%pre.1 umin %pre.0) U: full-set S: full-set220; CHECK-NEXT: %iv = phi i64 [ %iv.next, %loop ], [ 0, %ph ]221; CHECK-NEXT: --> {0,+,1}<nuw><%loop> U: [0,-9223372036854775808) S: [0,-9223372036854775808) Exits: %n LoopDispositions: { %loop: Computable }222; CHECK-NEXT: %iv.next = add i64 %iv, 1223; CHECK-NEXT: --> {1,+,1}<nuw><%loop> U: [1,-9223372036854775807) S: [1,-9223372036854775807) Exits: (1 + %n) LoopDispositions: { %loop: Computable }224; CHECK-NEXT: Determining loop execution counts for: @const_max_btc_32_or_order_1225; CHECK-NEXT: Loop %loop: backedge-taken count is %n226; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 9223372036854775807227; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is %n228; CHECK-NEXT: Loop %loop: Trip multiple is 1229;230entry:231 %pre.0 = icmp slt i64 %n, 33232 %pre.1 = icmp ne i64 %n, 0233 %and.pre = and i1 %pre.1, %pre.0234 br i1 %and.pre, label %ph, label %exit235 236ph:237 %pre.2 = icmp sgt i64 %n, 0238 br i1 %pre.2, label %loop, label %exit239 240loop:241 %iv = phi i64 [ %iv.next, %loop ], [ 0, %ph ]242 call void @foo()243 %iv.next = add i64 %iv, 1244 %ec = icmp eq i64 %iv, %n245 br i1 %ec, label %exit, label %loop246 247exit:248 ret void249}250 251; Same as @const_max_btc_32_or_order_1, but with operands in the OR swapped.252define void @const_max_btc_32_or_order_2(i64 %n) {253; CHECK-LABEL: 'const_max_btc_32_or_order_2'254; CHECK-NEXT: Classifying expressions for: @const_max_btc_32_or_order_2255; CHECK-NEXT: %and.pre = and i1 %pre.0, %pre.1256; CHECK-NEXT: --> (%pre.0 umin %pre.1) U: full-set S: full-set257; CHECK-NEXT: %iv = phi i64 [ %iv.next, %loop ], [ 0, %ph ]258; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,33) S: [0,33) Exits: %n LoopDispositions: { %loop: Computable }259; CHECK-NEXT: %iv.next = add i64 %iv, 1260; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,34) S: [1,34) Exits: (1 + %n) LoopDispositions: { %loop: Computable }261; CHECK-NEXT: Determining loop execution counts for: @const_max_btc_32_or_order_2262; CHECK-NEXT: Loop %loop: backedge-taken count is %n263; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 32264; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is %n265; CHECK-NEXT: Loop %loop: Trip multiple is 1266;267entry:268 %pre.0 = icmp slt i64 %n, 33269 %pre.1 = icmp ne i64 %n, 0270 %and.pre = and i1 %pre.0, %pre.1271 br i1 %and.pre, label %ph, label %exit272 273ph:274 %pre.2 = icmp sgt i64 %n, 0275 br i1 %pre.2, label %loop, label %exit276 277loop:278 %iv = phi i64 [ %iv.next, %loop ], [ 0, %ph ]279 call void @foo()280 %iv.next = add i64 %iv, 1281 %ec = icmp eq i64 %iv, %n282 br i1 %ec, label %exit, label %loop283 284exit:285 ret void286}287 288declare void @foo()289