brintos

brintos / llvm-project-archived public Read only

0
0
Text · 78.2 KiB · d5a2181 Raw
1659 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 4; Test case for PR40961. The loop guard limit the constant max backedge-taken count.5 6define void @test_guard_less_than_16(ptr nocapture %a, i64 %i) {7; CHECK-LABEL: 'test_guard_less_than_16'8; CHECK-NEXT:  Classifying expressions for: @test_guard_less_than_169; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]10; CHECK-NEXT:    --> {%i,+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 15 LoopDispositions: { %loop: Computable }11; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %a, i64 %iv12; CHECK-NEXT:    --> {((4 * %i) + %a),+,4}<%loop> U: full-set S: full-set Exits: (60 + %a) LoopDispositions: { %loop: Computable }13; CHECK-NEXT:    %iv.next = add nuw nsw i64 %iv, 114; CHECK-NEXT:    --> {(1 + %i),+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 16 LoopDispositions: { %loop: Computable }15; CHECK-NEXT:  Determining loop execution counts for: @test_guard_less_than_1616; CHECK-NEXT:  Loop %loop: backedge-taken count is (15 + (-1 * %i))17; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 1518; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (15 + (-1 * %i))19; CHECK-NEXT:  Loop %loop: Trip multiple is 120;21entry:22  %cmp3 = icmp ult i64 %i, 1623  br i1 %cmp3, label %loop, label %exit24 25loop:26  %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]27  %idx = getelementptr inbounds i32, ptr %a, i64 %iv28  store i32 1, ptr %idx, align 429  %iv.next = add nuw nsw i64 %iv, 130  %exitcond = icmp eq i64 %iv.next, 1631  br i1 %exitcond, label %exit, label %loop32 33exit:34  ret void35}36 37define void @test_guard_less_than_16_operands_swapped(ptr nocapture %a, i64 %i) {38; CHECK-LABEL: 'test_guard_less_than_16_operands_swapped'39; CHECK-NEXT:  Classifying expressions for: @test_guard_less_than_16_operands_swapped40; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]41; CHECK-NEXT:    --> {%i,+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 15 LoopDispositions: { %loop: Computable }42; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %a, i64 %iv43; CHECK-NEXT:    --> {((4 * %i) + %a),+,4}<%loop> U: full-set S: full-set Exits: (60 + %a) LoopDispositions: { %loop: Computable }44; CHECK-NEXT:    %iv.next = add nuw nsw i64 %iv, 145; CHECK-NEXT:    --> {(1 + %i),+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 16 LoopDispositions: { %loop: Computable }46; CHECK-NEXT:  Determining loop execution counts for: @test_guard_less_than_16_operands_swapped47; CHECK-NEXT:  Loop %loop: backedge-taken count is (15 + (-1 * %i))48; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 1549; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (15 + (-1 * %i))50; CHECK-NEXT:  Loop %loop: Trip multiple is 151;52entry:53  %cmp3 = icmp ugt i64 16, %i54  br i1 %cmp3, label %loop, label %exit55 56loop:57  %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]58  %idx = getelementptr inbounds i32, ptr %a, i64 %iv59  store i32 1, ptr %idx, align 460  %iv.next = add nuw nsw i64 %iv, 161  %exitcond = icmp eq i64 %iv.next, 1662  br i1 %exitcond, label %exit, label %loop63 64exit:65  ret void66}67 68define void @test_guard_less_than_16_branches_flipped(ptr nocapture %a, i64 %i) {69; CHECK-LABEL: 'test_guard_less_than_16_branches_flipped'70; CHECK-NEXT:  Classifying expressions for: @test_guard_less_than_16_branches_flipped71; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]72; CHECK-NEXT:    --> {%i,+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 15 LoopDispositions: { %loop: Computable }73; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %a, i64 %iv74; CHECK-NEXT:    --> {((4 * %i) + %a),+,4}<%loop> U: full-set S: full-set Exits: (60 + %a) LoopDispositions: { %loop: Computable }75; CHECK-NEXT:    %iv.next = add nuw nsw i64 %iv, 176; CHECK-NEXT:    --> {(1 + %i),+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 16 LoopDispositions: { %loop: Computable }77; CHECK-NEXT:  Determining loop execution counts for: @test_guard_less_than_16_branches_flipped78; CHECK-NEXT:  Loop %loop: backedge-taken count is (15 + (-1 * %i))79; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 -180; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (15 + (-1 * %i))81; CHECK-NEXT:  Loop %loop: Trip multiple is 182;83entry:84  %cmp3 = icmp ult i64 %i, 1685  br i1 %cmp3, label %exit, label %loop86 87loop:88  %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]89  %idx = getelementptr inbounds i32, ptr %a, i64 %iv90  store i32 1, ptr %idx, align 491  %iv.next = add nuw nsw i64 %iv, 192  %exitcond = icmp eq i64 %iv.next, 1693  br i1 %exitcond, label %exit, label %loop94 95exit:96  ret void97}98 99define void @test_guard_uge_16_branches_flipped(ptr nocapture %a, i64 %i) {100; CHECK-LABEL: 'test_guard_uge_16_branches_flipped'101; CHECK-NEXT:  Classifying expressions for: @test_guard_uge_16_branches_flipped102; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]103; CHECK-NEXT:    --> {%i,+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 15 LoopDispositions: { %loop: Computable }104; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %a, i64 %iv105; CHECK-NEXT:    --> {((4 * %i) + %a),+,4}<%loop> U: full-set S: full-set Exits: (60 + %a) LoopDispositions: { %loop: Computable }106; CHECK-NEXT:    %iv.next = add nuw nsw i64 %iv, 1107; CHECK-NEXT:    --> {(1 + %i),+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 16 LoopDispositions: { %loop: Computable }108; CHECK-NEXT:  Determining loop execution counts for: @test_guard_uge_16_branches_flipped109; CHECK-NEXT:  Loop %loop: backedge-taken count is (15 + (-1 * %i))110; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 15111; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (15 + (-1 * %i))112; CHECK-NEXT:  Loop %loop: Trip multiple is 1113;114entry:115  %cmp3 = icmp uge i64 %i, 16116  br i1 %cmp3, label %exit, label %loop117 118loop:119  %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]120  %idx = getelementptr inbounds i32, ptr %a, i64 %iv121  store i32 1, ptr %idx, align 4122  %iv.next = add nuw nsw i64 %iv, 1123  %exitcond = icmp eq i64 %iv.next, 16124  br i1 %exitcond, label %exit, label %loop125 126exit:127  ret void128}129 130define void @test_guard_eq_12(ptr nocapture %a, i64 %N) {131; CHECK-LABEL: 'test_guard_eq_12'132; CHECK-NEXT:  Classifying expressions for: @test_guard_eq_12133; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]134; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,13) S: [0,13) Exits: %N LoopDispositions: { %loop: Computable }135; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %a, i64 %iv136; CHECK-NEXT:    --> {%a,+,4}<nuw><%loop> U: full-set S: full-set Exits: ((4 * %N) + %a) LoopDispositions: { %loop: Computable }137; CHECK-NEXT:    %iv.next = add nuw nsw i64 %iv, 1138; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,14) S: [1,14) Exits: (1 + %N) LoopDispositions: { %loop: Computable }139; CHECK-NEXT:  Determining loop execution counts for: @test_guard_eq_12140; CHECK-NEXT:  Loop %loop: backedge-taken count is %N141; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 12142; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is %N143; CHECK-NEXT:  Loop %loop: Trip multiple is 13144;145entry:146  %c.1 = icmp eq i64 %N, 12147  br i1 %c.1, label %loop, label %exit148 149loop:150  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]151  %idx = getelementptr inbounds i32, ptr %a, i64 %iv152  store i32 1, ptr %idx, align 4153  %iv.next = add nuw nsw i64 %iv, 1154  %exitcond = icmp eq i64 %iv, %N155  br i1 %exitcond, label %exit, label %loop156 157exit:158  ret void159}160 161define void @test_guard_ule_12(ptr nocapture %a, i64 %N) {162; CHECK-LABEL: 'test_guard_ule_12'163; CHECK-NEXT:  Classifying expressions for: @test_guard_ule_12164; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]165; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,13) S: [0,13) Exits: %N LoopDispositions: { %loop: Computable }166; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %a, i64 %iv167; CHECK-NEXT:    --> {%a,+,4}<nuw><%loop> U: full-set S: full-set Exits: ((4 * %N) + %a) LoopDispositions: { %loop: Computable }168; CHECK-NEXT:    %iv.next = add nuw nsw i64 %iv, 1169; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,14) S: [1,14) Exits: (1 + %N) LoopDispositions: { %loop: Computable }170; CHECK-NEXT:  Determining loop execution counts for: @test_guard_ule_12171; CHECK-NEXT:  Loop %loop: backedge-taken count is %N172; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 12173; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is %N174; CHECK-NEXT:  Loop %loop: Trip multiple is 1175;176entry:177  %c.1 = icmp ule i64 %N, 12178  br i1 %c.1, label %loop, label %exit179 180loop:181  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]182  %idx = getelementptr inbounds i32, ptr %a, i64 %iv183  store i32 1, ptr %idx, align 4184  %iv.next = add nuw nsw i64 %iv, 1185  %exitcond = icmp eq i64 %iv, %N186  br i1 %exitcond, label %exit, label %loop187 188exit:189  ret void190}191 192define void @test_guard_ule_12_step2(ptr nocapture %a, i64 %N) {193; CHECK-LABEL: 'test_guard_ule_12_step2'194; CHECK-NEXT:  Classifying expressions for: @test_guard_ule_12_step2195; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]196; CHECK-NEXT:    --> {0,+,2}<nuw><nsw><%loop> U: [0,13) S: [0,13) Exits: (2 * (%N /u 2))<nuw> LoopDispositions: { %loop: Computable }197; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %a, i64 %iv198; CHECK-NEXT:    --> {%a,+,8}<nuw><%loop> U: full-set S: full-set Exits: ((8 * (%N /u 2)) + %a) LoopDispositions: { %loop: Computable }199; CHECK-NEXT:    %iv.next = add nuw nsw i64 %iv, 2200; CHECK-NEXT:    --> {2,+,2}<nuw><nsw><%loop> U: [2,15) S: [2,15) Exits: (2 + (2 * (%N /u 2))<nuw>) LoopDispositions: { %loop: Computable }201; CHECK-NEXT:  Determining loop execution counts for: @test_guard_ule_12_step2202; CHECK-NEXT:  Loop %loop: backedge-taken count is (%N /u 2)203; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 6204; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (%N /u 2)205; CHECK-NEXT:  Loop %loop: Trip multiple is 1206;207entry:208  %c.1 = icmp ule i64 %N, 12209  br i1 %c.1, label %loop, label %exit210 211loop:212  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]213  %idx = getelementptr inbounds i32, ptr %a, i64 %iv214  store i32 1, ptr %idx, align 4215  %iv.next = add nuw nsw i64 %iv, 2216  %exitcond = icmp eq i64 %iv, %N217  br i1 %exitcond, label %exit, label %loop218 219exit:220  ret void221}222 223; The guards here reference each other in a cycle.224define void @test_multiple_var_guards_cycle(ptr nocapture %a, i64 %i, i64 %N) {225; CHECK-LABEL: 'test_multiple_var_guards_cycle'226; CHECK-NEXT:  Classifying expressions for: @test_multiple_var_guards_cycle227; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]228; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,-9223372036854775808) S: [0,-9223372036854775808) Exits: %N LoopDispositions: { %loop: Computable }229; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %a, i64 %iv230; CHECK-NEXT:    --> {%a,+,4}<nuw><%loop> U: full-set S: full-set Exits: ((4 * %N) + %a) LoopDispositions: { %loop: Computable }231; CHECK-NEXT:    %iv.next = add nuw nsw i64 %iv, 1232; CHECK-NEXT:    --> {1,+,1}<nuw><%loop> U: [1,-1) S: [1,-1) Exits: (1 + %N) LoopDispositions: { %loop: Computable }233; CHECK-NEXT:  Determining loop execution counts for: @test_multiple_var_guards_cycle234; CHECK-NEXT:  Loop %loop: backedge-taken count is %N235; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 -3236; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is %N237; CHECK-NEXT:  Loop %loop: Trip multiple is 1238;239entry:240  %c.1 = icmp ult i64 %N, %i241  br i1 %c.1, label %guardbb, label %exit242 243guardbb:244  %c.2 = icmp ult i64 %i, %N245  br i1 %c.2, label %loop, label %exit246 247loop:248  %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]249  %idx = getelementptr inbounds i32, ptr %a, i64 %iv250  store i32 1, ptr %idx, align 4251  %iv.next = add nuw nsw i64 %iv, 1252  %exitcond = icmp eq i64 %iv, %N253  br i1 %exitcond, label %exit, label %loop254 255exit:256  ret void257}258 259define void @test_guard_ult_ne(ptr nocapture readonly %data, i64 %count) {260; CHECK-LABEL: 'test_guard_ult_ne'261; CHECK-NEXT:  Classifying expressions for: @test_guard_ult_ne262; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]263; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,4) S: [0,4) Exits: (-1 + %count) LoopDispositions: { %loop: Computable }264; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %data, i64 %iv265; CHECK-NEXT:    --> {%data,+,4}<nuw><%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %data) LoopDispositions: { %loop: Computable }266; CHECK-NEXT:    %iv.next = add nuw i64 %iv, 1267; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,5) S: [1,5) Exits: %count LoopDispositions: { %loop: Computable }268; CHECK-NEXT:  Determining loop execution counts for: @test_guard_ult_ne269; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %count)270; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 3271; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %count)272; CHECK-NEXT:  Loop %loop: Trip multiple is 1273;274entry:275  %cmp.ult = icmp ult i64 %count, 5276  br i1 %cmp.ult, label %guardbb, label %exit277 278guardbb:279  %cmp.ne = icmp ne i64 %count, 0280  br i1 %cmp.ne, label %loop, label %exit281 282loop:283  %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]284  %idx = getelementptr inbounds i32, ptr %data, i64 %iv285  store i32 1, ptr %idx, align 4286  %iv.next = add nuw i64 %iv, 1287  %exitcond.not = icmp eq i64 %iv.next, %count288  br i1 %exitcond.not, label %exit, label %loop289 290exit:291  ret void292}293 294define void @test_guard_ne_ult(ptr nocapture readonly %data, i64 %count) {295; CHECK-LABEL: 'test_guard_ne_ult'296; CHECK-NEXT:  Classifying expressions for: @test_guard_ne_ult297; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]298; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,4) S: [0,4) Exits: (-1 + %count) LoopDispositions: { %loop: Computable }299; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %data, i64 %iv300; CHECK-NEXT:    --> {%data,+,4}<nuw><%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %data) LoopDispositions: { %loop: Computable }301; CHECK-NEXT:    %iv.next = add nuw i64 %iv, 1302; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,5) S: [1,5) Exits: %count LoopDispositions: { %loop: Computable }303; CHECK-NEXT:  Determining loop execution counts for: @test_guard_ne_ult304; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %count)305; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 3306; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %count)307; CHECK-NEXT:  Loop %loop: Trip multiple is 1308;309entry:310  %cmp.ne = icmp ne i64 %count, 0311  br i1 %cmp.ne, label %guardbb, label %exit312 313guardbb:314  %cmp.ult = icmp ult i64 %count, 5315  br i1 %cmp.ult, label %loop, label %exit316 317loop:318  %iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]319  %idx = getelementptr inbounds i32, ptr %data, i64 %iv320  store i32 1, ptr %idx, align 4321  %iv.next = add nuw i64 %iv, 1322  %exitcond.not = icmp eq i64 %iv.next, %count323  br i1 %exitcond.not, label %exit, label %loop324 325exit:326  ret void327}328 329define void @test_guard_if_and_enter(ptr nocapture readonly %data, i64 %count) {330; CHECK-LABEL: 'test_guard_if_and_enter'331; CHECK-NEXT:  Classifying expressions for: @test_guard_if_and_enter332; CHECK-NEXT:    %cmp.and = and i1 %cmp.ult, %cmp.ne333; CHECK-NEXT:    --> (%cmp.ult umin %cmp.ne) U: full-set S: full-set334; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]335; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,4) S: [0,4) Exits: (-1 + %count) LoopDispositions: { %loop: Computable }336; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %data, i64 %iv337; CHECK-NEXT:    --> {%data,+,4}<nuw><%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %data) LoopDispositions: { %loop: Computable }338; CHECK-NEXT:    %iv.next = add nuw i64 %iv, 1339; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,5) S: [1,5) Exits: %count LoopDispositions: { %loop: Computable }340; CHECK-NEXT:  Determining loop execution counts for: @test_guard_if_and_enter341; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %count)342; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 3343; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %count)344; CHECK-NEXT:  Loop %loop: Trip multiple is 1345;346entry:347  %cmp.ult = icmp ult i64 %count, 5348  %cmp.ne = icmp ne i64 %count, 0349  %cmp.and = and i1 %cmp.ult, %cmp.ne350  br i1 %cmp.and, label %loop, label %exit351 352loop:353  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]354  %idx = getelementptr inbounds i32, ptr %data, i64 %iv355  store i32 1, ptr %idx, align 4356  %iv.next = add nuw i64 %iv, 1357  %exitcond.not = icmp eq i64 %iv.next, %count358  br i1 %exitcond.not, label %exit, label %loop359 360exit:361  ret void362}363 364define void @test_guard_if_and_skip(ptr nocapture readonly %data, i64 %count) {365; CHECK-LABEL: 'test_guard_if_and_skip'366; CHECK-NEXT:  Classifying expressions for: @test_guard_if_and_skip367; CHECK-NEXT:    %cmp.and = and i1 %cmp.ult, %cmp.ne368; CHECK-NEXT:    --> (%cmp.ult umin %cmp.ne) U: full-set S: full-set369; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]370; CHECK-NEXT:    --> {0,+,1}<nuw><%loop> U: full-set S: full-set Exits: (-1 + %count) LoopDispositions: { %loop: Computable }371; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %data, i64 %iv372; CHECK-NEXT:    --> {%data,+,4}<%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %data) LoopDispositions: { %loop: Computable }373; CHECK-NEXT:    %iv.next = add nuw i64 %iv, 1374; CHECK-NEXT:    --> {1,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: %count LoopDispositions: { %loop: Computable }375; CHECK-NEXT:  Determining loop execution counts for: @test_guard_if_and_skip376; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %count)377; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 -1378; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %count)379; CHECK-NEXT:  Loop %loop: Trip multiple is 1380;381entry:382  %cmp.ult = icmp ult i64 %count, 5383  %cmp.ne = icmp ne i64 %count, 0384  %cmp.and = and i1 %cmp.ult, %cmp.ne385  br i1 %cmp.and, label %exit, label %loop386 387loop:388  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]389  %idx = getelementptr inbounds i32, ptr %data, i64 %iv390  store i32 1, ptr %idx, align 4391  %iv.next = add nuw i64 %iv, 1392  %exitcond.not = icmp eq i64 %iv.next, %count393  br i1 %exitcond.not, label %exit, label %loop394 395exit:396  ret void397}398 399define void @test_guard_if_and_and(ptr nocapture readonly %data, i64 %count, i1 %c) {400; CHECK-LABEL: 'test_guard_if_and_and'401; CHECK-NEXT:  Classifying expressions for: @test_guard_if_and_and402; CHECK-NEXT:    %cmp.and1 = and i1 %c, %cmp.ne403; CHECK-NEXT:    --> (%c umin %cmp.ne) U: full-set S: full-set404; CHECK-NEXT:    %cmp.and = and i1 %cmp.ult, %cmp.and1405; CHECK-NEXT:    --> (%c umin %cmp.ult umin %cmp.ne) U: full-set S: full-set406; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]407; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,4) S: [0,4) Exits: (-1 + %count) LoopDispositions: { %loop: Computable }408; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %data, i64 %iv409; CHECK-NEXT:    --> {%data,+,4}<nuw><%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %data) LoopDispositions: { %loop: Computable }410; CHECK-NEXT:    %iv.next = add nuw i64 %iv, 1411; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,5) S: [1,5) Exits: %count LoopDispositions: { %loop: Computable }412; CHECK-NEXT:  Determining loop execution counts for: @test_guard_if_and_and413; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %count)414; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 3415; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %count)416; CHECK-NEXT:  Loop %loop: Trip multiple is 1417;418entry:419  %cmp.ult = icmp ult i64 %count, 5420  %cmp.ne = icmp ne i64 %count, 0421  %cmp.and1 = and i1 %c, %cmp.ne422  %cmp.and = and i1 %cmp.ult, %cmp.and1423  br i1 %cmp.and, label %loop, label %exit424 425loop:426  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]427  %idx = getelementptr inbounds i32, ptr %data, i64 %iv428  store i32 1, ptr %idx, align 4429  %iv.next = add nuw i64 %iv, 1430  %exitcond.not = icmp eq i64 %iv.next, %count431  br i1 %exitcond.not, label %exit, label %loop432 433exit:434  ret void435}436 437define void @test_guard_if_and_or(ptr nocapture readonly %data, i64 %count, i1 %c) {438; CHECK-LABEL: 'test_guard_if_and_or'439; CHECK-NEXT:  Classifying expressions for: @test_guard_if_and_or440; CHECK-NEXT:    %cmp.or = or i1 %c, %cmp.ne441; CHECK-NEXT:    --> (%c umax %cmp.ne) U: full-set S: full-set442; CHECK-NEXT:    %cmp.and = and i1 %cmp.ult, %cmp.or443; CHECK-NEXT:    --> ((%c umax %cmp.ne) umin %cmp.ult) U: full-set S: full-set444; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]445; CHECK-NEXT:    --> {0,+,1}<nuw><%loop> U: full-set S: full-set Exits: (-1 + %count) LoopDispositions: { %loop: Computable }446; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %data, i64 %iv447; CHECK-NEXT:    --> {%data,+,4}<%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %data) LoopDispositions: { %loop: Computable }448; CHECK-NEXT:    %iv.next = add nuw i64 %iv, 1449; CHECK-NEXT:    --> {1,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: %count LoopDispositions: { %loop: Computable }450; CHECK-NEXT:  Determining loop execution counts for: @test_guard_if_and_or451; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %count)452; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 -1453; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %count)454; CHECK-NEXT:  Loop %loop: Trip multiple is 1455;456entry:457  %cmp.ult = icmp ult i64 %count, 5458  %cmp.ne = icmp ne i64 %count, 0459  %cmp.or = or i1 %c, %cmp.ne460  %cmp.and = and i1 %cmp.ult, %cmp.or461  br i1 %cmp.and, label %loop, label %exit462 463loop:464  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]465  %idx = getelementptr inbounds i32, ptr %data, i64 %iv466  store i32 1, ptr %idx, align 4467  %iv.next = add nuw i64 %iv, 1468  %exitcond.not = icmp eq i64 %iv.next, %count469  br i1 %exitcond.not, label %exit, label %loop470 471exit:472  ret void473}474 475define void @test_guard_if_or_skip(ptr nocapture readonly %data, i64 %count) {476; CHECK-LABEL: 'test_guard_if_or_skip'477; CHECK-NEXT:  Classifying expressions for: @test_guard_if_or_skip478; CHECK-NEXT:    %cmp.or = or i1 %cmp.uge, %cmp.eq479; CHECK-NEXT:    --> (%cmp.uge umax %cmp.eq) U: full-set S: full-set480; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]481; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,4) S: [0,4) Exits: (-1 + %count) LoopDispositions: { %loop: Computable }482; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %data, i64 %iv483; CHECK-NEXT:    --> {%data,+,4}<nuw><%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %data) LoopDispositions: { %loop: Computable }484; CHECK-NEXT:    %iv.next = add nuw i64 %iv, 1485; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,5) S: [1,5) Exits: %count LoopDispositions: { %loop: Computable }486; CHECK-NEXT:  Determining loop execution counts for: @test_guard_if_or_skip487; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %count)488; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 3489; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %count)490; CHECK-NEXT:  Loop %loop: Trip multiple is 1491;492entry:493  %cmp.uge = icmp uge i64 %count, 5494  %cmp.eq = icmp eq i64 %count, 0495  %cmp.or = or i1 %cmp.uge, %cmp.eq496  br i1 %cmp.or, label %exit, label %loop497 498loop:499  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]500  %idx = getelementptr inbounds i32, ptr %data, i64 %iv501  store i32 1, ptr %idx, align 4502  %iv.next = add nuw i64 %iv, 1503  %exitcond.not = icmp eq i64 %iv.next, %count504  br i1 %exitcond.not, label %exit, label %loop505 506exit:507  ret void508}509 510define void @test_guard_if_or_enter(ptr nocapture readonly %data, i64 %count) {511; CHECK-LABEL: 'test_guard_if_or_enter'512; CHECK-NEXT:  Classifying expressions for: @test_guard_if_or_enter513; CHECK-NEXT:    %cmp.or = or i1 %cmp.uge, %cmp.eq514; CHECK-NEXT:    --> (%cmp.uge umax %cmp.eq) U: full-set S: full-set515; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]516; CHECK-NEXT:    --> {0,+,1}<nuw><%loop> U: full-set S: full-set Exits: (-1 + %count) LoopDispositions: { %loop: Computable }517; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %data, i64 %iv518; CHECK-NEXT:    --> {%data,+,4}<%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %data) LoopDispositions: { %loop: Computable }519; CHECK-NEXT:    %iv.next = add nuw i64 %iv, 1520; CHECK-NEXT:    --> {1,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: %count LoopDispositions: { %loop: Computable }521; CHECK-NEXT:  Determining loop execution counts for: @test_guard_if_or_enter522; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %count)523; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 -1524; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %count)525; CHECK-NEXT:  Loop %loop: Trip multiple is 1526;527entry:528  %cmp.uge = icmp uge i64 %count, 5529  %cmp.eq = icmp eq i64 %count, 0530  %cmp.or = or i1 %cmp.uge, %cmp.eq531  br i1 %cmp.or, label %loop, label %exit532 533loop:534  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]535  %idx = getelementptr inbounds i32, ptr %data, i64 %iv536  store i32 1, ptr %idx, align 4537  %iv.next = add nuw i64 %iv, 1538  %exitcond.not = icmp eq i64 %iv.next, %count539  br i1 %exitcond.not, label %exit, label %loop540 541exit:542  ret void543}544 545define void @test_guard_if_or_or(ptr nocapture readonly %data, i64 %count, i1 %c) {546; CHECK-LABEL: 'test_guard_if_or_or'547; CHECK-NEXT:  Classifying expressions for: @test_guard_if_or_or548; CHECK-NEXT:    %cmp.or1 = or i1 %c, %cmp.eq549; CHECK-NEXT:    --> (%c umax %cmp.eq) U: full-set S: full-set550; CHECK-NEXT:    %cmp.or = or i1 %cmp.uge, %cmp.or1551; CHECK-NEXT:    --> (%c umax %cmp.uge umax %cmp.eq) U: full-set S: full-set552; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]553; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,4) S: [0,4) Exits: (-1 + %count) LoopDispositions: { %loop: Computable }554; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %data, i64 %iv555; CHECK-NEXT:    --> {%data,+,4}<nuw><%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %data) LoopDispositions: { %loop: Computable }556; CHECK-NEXT:    %iv.next = add nuw i64 %iv, 1557; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,5) S: [1,5) Exits: %count LoopDispositions: { %loop: Computable }558; CHECK-NEXT:  Determining loop execution counts for: @test_guard_if_or_or559; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %count)560; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 3561; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %count)562; CHECK-NEXT:  Loop %loop: Trip multiple is 1563;564entry:565  %cmp.uge = icmp uge i64 %count, 5566  %cmp.eq = icmp eq i64 %count, 0567  %cmp.or1 = or i1 %c, %cmp.eq568  %cmp.or = or i1 %cmp.uge, %cmp.or1569  br i1 %cmp.or, label %exit, label %loop570 571loop:572  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]573  %idx = getelementptr inbounds i32, ptr %data, i64 %iv574  store i32 1, ptr %idx, align 4575  %iv.next = add nuw i64 %iv, 1576  %exitcond.not = icmp eq i64 %iv.next, %count577  br i1 %exitcond.not, label %exit, label %loop578 579exit:580  ret void581}582 583define void @test_guard_if_or_and(ptr nocapture readonly %data, i64 %count, i1 %c) {584; CHECK-LABEL: 'test_guard_if_or_and'585; CHECK-NEXT:  Classifying expressions for: @test_guard_if_or_and586; CHECK-NEXT:    %cmp.and = and i1 %c, %cmp.eq587; CHECK-NEXT:    --> (%c umin %cmp.eq) U: full-set S: full-set588; CHECK-NEXT:    %cmp.or = or i1 %cmp.uge, %cmp.and589; CHECK-NEXT:    --> ((%c umin %cmp.eq) umax %cmp.uge) U: full-set S: full-set590; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]591; CHECK-NEXT:    --> {0,+,1}<nuw><%loop> U: full-set S: full-set Exits: (-1 + %count) LoopDispositions: { %loop: Computable }592; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %data, i64 %iv593; CHECK-NEXT:    --> {%data,+,4}<%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %data) LoopDispositions: { %loop: Computable }594; CHECK-NEXT:    %iv.next = add nuw i64 %iv, 1595; CHECK-NEXT:    --> {1,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: %count LoopDispositions: { %loop: Computable }596; CHECK-NEXT:  Determining loop execution counts for: @test_guard_if_or_and597; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %count)598; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 -1599; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %count)600; CHECK-NEXT:  Loop %loop: Trip multiple is 1601;602entry:603  %cmp.uge = icmp uge i64 %count, 5604  %cmp.eq = icmp eq i64 %count, 0605  %cmp.and = and i1 %c, %cmp.eq606  %cmp.or = or i1 %cmp.uge, %cmp.and607  br i1 %cmp.or, label %exit, label %loop608 609loop:610  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]611  %idx = getelementptr inbounds i32, ptr %data, i64 %iv612  store i32 1, ptr %idx, align 4613  %iv.next = add nuw i64 %iv, 1614  %exitcond.not = icmp eq i64 %iv.next, %count615  br i1 %exitcond.not, label %exit, label %loop616 617exit:618  ret void619}620 621; Test case for PR47247. Both the guard condition and the assume limit the622; constant max backedge-taken count.623 624define void @test_guard_and_assume(ptr nocapture readonly %data, i64 %count) {625; CHECK-LABEL: 'test_guard_and_assume'626; CHECK-NEXT:  Classifying expressions for: @test_guard_and_assume627; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]628; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,4) S: [0,4) Exits: (-1 + %count) LoopDispositions: { %loop: Computable }629; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %data, i64 %iv630; CHECK-NEXT:    --> {%data,+,4}<nuw><%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %data) LoopDispositions: { %loop: Computable }631; CHECK-NEXT:    %iv.next = add nuw i64 %iv, 1632; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,5) S: [1,5) Exits: %count LoopDispositions: { %loop: Computable }633; CHECK-NEXT:  Determining loop execution counts for: @test_guard_and_assume634; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %count)635; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 3636; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %count)637; CHECK-NEXT:  Loop %loop: Trip multiple is 1638;639entry:640  %cmp = icmp ult i64 %count, 5641  tail call void @llvm.assume(i1 %cmp)642  %cmp18.not = icmp eq i64 %count, 0643  br i1 %cmp18.not, label %exit, label %loop644 645loop:646  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]647  %idx = getelementptr inbounds i32, ptr %data, i64 %iv648  store i32 1, ptr %idx, align 4649  %iv.next = add nuw i64 %iv, 1650  %exitcond.not = icmp eq i64 %iv.next, %count651  br i1 %exitcond.not, label %exit, label %loop652 653exit:654  ret void655}656 657define void @test_guard_assume_and(ptr nocapture readonly %data, i64 %count) {658; CHECK-LABEL: 'test_guard_assume_and'659; CHECK-NEXT:  Classifying expressions for: @test_guard_assume_and660; CHECK-NEXT:    %cmp.and = and i1 %cmp.ult, %cmp.ne661; CHECK-NEXT:    --> (%cmp.ult umin %cmp.ne) U: full-set S: full-set662; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]663; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,4) S: [0,4) Exits: (-1 + %count) LoopDispositions: { %loop: Computable }664; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %data, i64 %iv665; CHECK-NEXT:    --> {%data,+,4}<nuw><%loop> U: full-set S: full-set Exits: (-4 + (4 * %count) + %data) LoopDispositions: { %loop: Computable }666; CHECK-NEXT:    %iv.next = add nuw i64 %iv, 1667; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,5) S: [1,5) Exits: %count LoopDispositions: { %loop: Computable }668; CHECK-NEXT:  Determining loop execution counts for: @test_guard_assume_and669; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %count)670; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 3671; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %count)672; CHECK-NEXT:  Loop %loop: Trip multiple is 1673;674entry:675  %cmp.ult = icmp ult i64 %count, 5676  %cmp.ne = icmp ne i64 %count, 0677  %cmp.and = and i1 %cmp.ult, %cmp.ne678  call void @llvm.assume(i1 %cmp.and)679  br label %loop680 681loop:682  %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]683  %idx = getelementptr inbounds i32, ptr %data, i64 %iv684  store i32 1, ptr %idx, align 4685  %iv.next = add nuw i64 %iv, 1686  %exitcond.not = icmp eq i64 %iv.next, %count687  br i1 %exitcond.not, label %exit, label %loop688 689exit:690  ret void691}692 693; Function Attrs: nounwind willreturn694declare void @llvm.assume(i1 noundef)695 696define void @guard_pessimizes_analysis_step1(i1 %c, i32 %N) {697; CHECK-LABEL: 'guard_pessimizes_analysis_step1'698; CHECK-NEXT:  Classifying expressions for: @guard_pessimizes_analysis_step1699; CHECK-NEXT:    %init = phi i32 [ 2, %entry ], [ 3, %bb1 ]700; CHECK-NEXT:    --> %init U: [2,4) S: [2,4)701; CHECK-NEXT:    %iv = phi i32 [ %iv.next, %loop ], [ %init, %loop.ph ]702; CHECK-NEXT:    --> {%init,+,1}<nuw><nsw><%loop> U: [2,11) S: [2,11) Exits: 9 LoopDispositions: { %loop: Computable }703; CHECK-NEXT:    %iv.next = add i32 %iv, 1704; CHECK-NEXT:    --> {(1 + %init)<nuw><nsw>,+,1}<nuw><nsw><%loop> U: [3,12) S: [3,12) Exits: 10 LoopDispositions: { %loop: Computable }705; CHECK-NEXT:  Determining loop execution counts for: @guard_pessimizes_analysis_step1706; CHECK-NEXT:  Loop %loop: backedge-taken count is (9 + (-1 * %init)<nsw>)<nsw>707; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 7708; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (9 + (-1 * %init)<nsw>)<nsw>709; CHECK-NEXT:  Loop %loop: Trip multiple is 1710;711entry:712  br i1 %c, label %bb1, label %guard713 714bb1:715  br label %guard716 717guard:718  %init = phi i32 [ 2, %entry ], [ 3, %bb1 ]719  %c.1 = icmp ult i32 %init, %N720  br i1 %c.1, label %loop.ph, label %exit721 722loop.ph:723  br label %loop724 725loop:726  %iv = phi i32 [ %iv.next, %loop ], [ %init, %loop.ph ]727  %iv.next = add i32 %iv, 1728  %exitcond = icmp eq i32 %iv.next, 10729  br i1 %exitcond, label %exit, label %loop730 731exit:732  ret void733}734 735define void @guard_pessimizes_analysis_step2(i1 %c, i32 %N) {736; CHECK-LABEL: 'guard_pessimizes_analysis_step2'737; CHECK-NEXT:  Classifying expressions for: @guard_pessimizes_analysis_step2738; CHECK-NEXT:    %init = phi i32 [ 2, %entry ], [ 3, %bb1 ]739; CHECK-NEXT:    --> %init U: [2,4) S: [2,4)740; CHECK-NEXT:    %iv = phi i32 [ %iv.next, %loop ], [ %init, %loop.ph ]741; CHECK-NEXT:    --> {%init,+,2}<nuw><nsw><%loop> U: [2,10) S: [2,10) Exits: ((2 * ((8 + (-1 * %init)<nsw>)<nsw> /u 2))<nuw><nsw> + %init) LoopDispositions: { %loop: Computable }742; CHECK-NEXT:    %iv.next = add nuw nsw i32 %iv, 2743; CHECK-NEXT:    --> {(2 + %init)<nuw><nsw>,+,2}<nuw><nsw><%loop> U: [4,12) S: [4,12) Exits: (2 + (2 * ((8 + (-1 * %init)<nsw>)<nsw> /u 2))<nuw><nsw> + %init) LoopDispositions: { %loop: Computable }744; CHECK-NEXT:  Determining loop execution counts for: @guard_pessimizes_analysis_step2745; CHECK-NEXT:  Loop %loop: backedge-taken count is ((8 + (-1 * %init)<nsw>)<nsw> /u 2)746; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 3747; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is ((8 + (-1 * %init)<nsw>)<nsw> /u 2)748; CHECK-NEXT:  Loop %loop: Trip multiple is 1749;750entry:751  br i1 %c, label %bb1, label %guard752 753bb1:754  br label %guard755 756guard:757  %init = phi i32 [ 2, %entry ], [ 3, %bb1 ]758  %c.1 = icmp ult i32 %init, %N759  br i1 %c.1, label %loop.ph, label %exit760 761loop.ph:762  br label %loop763 764loop:765  %iv = phi i32 [ %iv.next, %loop ], [ %init, %loop.ph ]766  %iv.next = add nuw nsw i32 %iv, 2767  %exitcond = icmp eq i32 %iv.next, 10768  br i1 %exitcond, label %exit, label %loop769 770exit:771  ret void772}773define void @crash(ptr %ptr) {774; CHECK-LABEL: 'crash'775; CHECK-NEXT:  Classifying expressions for: @crash776; CHECK-NEXT:    %text.addr.5 = phi ptr [ %incdec.ptr112, %while.cond111 ], [ null, %while.body ]777; CHECK-NEXT:    --> {null,+,-1}<nw><%while.cond111> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %while.cond111: Computable, %while.body: Variant }778; CHECK-NEXT:    %incdec.ptr112 = getelementptr inbounds i8, ptr %text.addr.5, i64 -1779; CHECK-NEXT:    --> {(-1 + null)<nuw><nsw>,+,-1}<nw><%while.cond111> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %while.cond111: Computable, %while.body: Variant }780; CHECK-NEXT:    %lastout.2271 = phi ptr [ %incdec.ptr126, %while.body125 ], [ %ptr, %while.end117 ]781; CHECK-NEXT:    --> {%ptr,+,1}<nuw><%while.body125> U: full-set S: full-set Exits: {(-2 + (-1 * (ptrtoint ptr %ptr to i64)) + %ptr),+,-1}<nw><%while.cond111> LoopDispositions: { %while.body125: Computable }782; CHECK-NEXT:    %incdec.ptr126 = getelementptr inbounds i8, ptr %lastout.2271, i64 1783; CHECK-NEXT:    --> {(1 + %ptr),+,1}<nuw><%while.body125> U: full-set S: full-set Exits: {(-1 + (-1 * (ptrtoint ptr %ptr to i64)) + %ptr),+,-1}<nw><%while.cond111> LoopDispositions: { %while.body125: Computable }784; CHECK-NEXT:  Determining loop execution counts for: @crash785; CHECK-NEXT:  Loop %while.body125: backedge-taken count is {(-2 + (-1 * (ptrtoint ptr %ptr to i64))),+,-1}<nw><%while.cond111>786; CHECK-NEXT:  Loop %while.body125: constant max backedge-taken count is i64 -2787; CHECK-NEXT:  Loop %while.body125: symbolic max backedge-taken count is {(-2 + (-1 * (ptrtoint ptr %ptr to i64))),+,-1}<nw><%while.cond111>788; CHECK-NEXT:  Loop %while.body125: Trip multiple is 1789; CHECK-NEXT:  Loop %while.cond111: Unpredictable backedge-taken count.790; CHECK-NEXT:  Loop %while.cond111: Unpredictable constant max backedge-taken count.791; CHECK-NEXT:  Loop %while.cond111: Unpredictable symbolic max backedge-taken count.792; CHECK-NEXT:  Loop %while.body: Unpredictable backedge-taken count.793; CHECK-NEXT:  Loop %while.body: Unpredictable constant max backedge-taken count.794; CHECK-NEXT:  Loop %while.body: Unpredictable symbolic max backedge-taken count.795;796entry:797  br label %while.body798 799while.body:800  br label %while.cond111801 802while.cond111:803  %text.addr.5 = phi ptr [ %incdec.ptr112, %while.cond111 ], [ null, %while.body ]804  %incdec.ptr112 = getelementptr inbounds i8, ptr %text.addr.5, i64 -1805  br i1 false, label %while.end117, label %while.cond111806 807while.end117:808  %cmp118 = icmp ult ptr %ptr, %incdec.ptr112809  br i1 %cmp118, label %while.body125, label %while.cond134.preheader810 811 812while.cond134.preheader:813  br label %while.body814 815while.body125:816  %lastout.2271 = phi ptr [ %incdec.ptr126, %while.body125 ], [ %ptr, %while.end117 ]817  %incdec.ptr126 = getelementptr inbounds i8, ptr %lastout.2271, i64 1818  %exitcond.not = icmp eq ptr %incdec.ptr126, %incdec.ptr112819  br i1 %exitcond.not, label %while.end129, label %while.body125820 821while.end129:                                     ; preds = %while.body125822  ret void823}824 825define void @test_guard_uge(i32 %blockSize) {826; CHECK-LABEL: 'test_guard_uge'827; CHECK-NEXT:  Classifying expressions for: @test_guard_uge828; CHECK-NEXT:    %shr = lshr i32 %blockSize, 2829; CHECK-NEXT:    --> (%blockSize /u 4) U: [0,1073741824) S: [0,1073741824)830; CHECK-NEXT:    %iv = phi i32 [ %dec, %while.body ], [ %shr, %while.body.preheader ]831; CHECK-NEXT:    --> {(%blockSize /u 4),+,-1}<nsw><%while.body> U: [-1073741822,1073741824) S: [-1073741822,1073741824) Exits: 1 LoopDispositions: { %while.body: Computable }832; CHECK-NEXT:    %dec = add i32 %iv, -1833; CHECK-NEXT:    --> {(-1 + (%blockSize /u 4))<nsw>,+,-1}<nsw><%while.body> U: [-1073741823,1073741823) S: [-1073741823,1073741823) Exits: 0 LoopDispositions: { %while.body: Computable }834; CHECK-NEXT:  Determining loop execution counts for: @test_guard_uge835; CHECK-NEXT:  Loop %while.body: backedge-taken count is (-1 + (%blockSize /u 4))<nsw>836; CHECK-NEXT:  Loop %while.body: constant max backedge-taken count is i32 1073741822837; CHECK-NEXT:  Loop %while.body: symbolic max backedge-taken count is (-1 + (%blockSize /u 4))<nsw>838; CHECK-NEXT:  Loop %while.body: Trip multiple is 1839;840  %shr = lshr i32 %blockSize, 2841  %guard = icmp uge i32 %blockSize, 4842  br i1 %guard, label %while.body.preheader, label %while.end843 844while.body.preheader:845  br label %while.body846 847while.body:848  %iv = phi i32 [ %dec, %while.body ], [ %shr, %while.body.preheader ]849  %dec = add i32 %iv, -1850  %cmp.not = icmp eq i32 %dec, 0851  br i1 %cmp.not, label %while.end.loopexit, label %while.body852 853while.end.loopexit:854  br label %while.end855 856while.end:857  ret void858}859 860define void @test_guard_ugt(i32 %blockSize) {861; CHECK-LABEL: 'test_guard_ugt'862; CHECK-NEXT:  Classifying expressions for: @test_guard_ugt863; CHECK-NEXT:    %shr = lshr i32 %blockSize, 2864; CHECK-NEXT:    --> (%blockSize /u 4) U: [0,1073741824) S: [0,1073741824)865; CHECK-NEXT:    %iv = phi i32 [ %dec, %while.body ], [ %shr, %while.body.preheader ]866; CHECK-NEXT:    --> {(%blockSize /u 4),+,-1}<nsw><%while.body> U: [-1073741822,1073741824) S: [-1073741822,1073741824) Exits: 1 LoopDispositions: { %while.body: Computable }867; CHECK-NEXT:    %dec = add i32 %iv, -1868; CHECK-NEXT:    --> {(-1 + (%blockSize /u 4))<nsw>,+,-1}<nsw><%while.body> U: [-1073741823,1073741823) S: [-1073741823,1073741823) Exits: 0 LoopDispositions: { %while.body: Computable }869; CHECK-NEXT:  Determining loop execution counts for: @test_guard_ugt870; CHECK-NEXT:  Loop %while.body: backedge-taken count is (-1 + (%blockSize /u 4))<nsw>871; CHECK-NEXT:  Loop %while.body: constant max backedge-taken count is i32 1073741822872; CHECK-NEXT:  Loop %while.body: symbolic max backedge-taken count is (-1 + (%blockSize /u 4))<nsw>873; CHECK-NEXT:  Loop %while.body: Trip multiple is 1874;875  %shr = lshr i32 %blockSize, 2876  %guard = icmp ugt i32 %blockSize, 3877  br i1 %guard, label %while.body.preheader, label %while.end878 879while.body.preheader:880  br label %while.body881 882while.body:883  %iv = phi i32 [ %dec, %while.body ], [ %shr, %while.body.preheader ]884  %dec = add i32 %iv, -1885  %cmp.not = icmp eq i32 %dec, 0886  br i1 %cmp.not, label %while.end.loopexit, label %while.body887 888while.end.loopexit:889  br label %while.end890 891while.end:892  ret void893}894 895define void @test_guard_uge_and_ule(i32 %blockSize) {896; CHECK-LABEL: 'test_guard_uge_and_ule'897; CHECK-NEXT:  Classifying expressions for: @test_guard_uge_and_ule898; CHECK-NEXT:    %shr = lshr i32 %blockSize, 2899; CHECK-NEXT:    --> (%blockSize /u 4) U: [0,1073741824) S: [0,1073741824)900; CHECK-NEXT:    %iv = phi i32 [ %dec, %while.body ], [ %shr, %while.body.preheader ]901; CHECK-NEXT:    --> {(%blockSize /u 4),+,-1}<nsw><%while.body> U: [-255,1073741824) S: [-255,1073741824) Exits: 1 LoopDispositions: { %while.body: Computable }902; CHECK-NEXT:    %dec = add i32 %iv, -1903; CHECK-NEXT:    --> {(-1 + (%blockSize /u 4))<nsw>,+,-1}<nsw><%while.body> U: [-256,1073741823) S: [-256,1073741823) Exits: 0 LoopDispositions: { %while.body: Computable }904; CHECK-NEXT:  Determining loop execution counts for: @test_guard_uge_and_ule905; CHECK-NEXT:  Loop %while.body: backedge-taken count is (-1 + (%blockSize /u 4))<nsw>906; CHECK-NEXT:  Loop %while.body: constant max backedge-taken count is i32 255907; CHECK-NEXT:  Loop %while.body: symbolic max backedge-taken count is (-1 + (%blockSize /u 4))<nsw>908; CHECK-NEXT:  Loop %while.body: Trip multiple is 1909;910  %shr = lshr i32 %blockSize, 2911  %guard1 = icmp uge i32 %blockSize, 4912  br i1 %guard1, label %while.guard, label %while.end913 914while.guard:915  %guard2 = icmp ule i32 %blockSize, 1024916  br i1 %guard2, label %while.body.preheader, label %while.end917 918while.body.preheader:919  br label %while.body920 921while.body:922  %iv = phi i32 [ %dec, %while.body ], [ %shr, %while.body.preheader ]923  %dec = add i32 %iv, -1924  %cmp.not = icmp eq i32 %dec, 0925  br i1 %cmp.not, label %while.end.loopexit, label %while.body926 927while.end.loopexit:928  br label %while.end929 930while.end:931  ret void932}933 934define void @test_guard_ugt_and_ult(i32 %blockSize) {935; CHECK-LABEL: 'test_guard_ugt_and_ult'936; CHECK-NEXT:  Classifying expressions for: @test_guard_ugt_and_ult937; CHECK-NEXT:    %shr = lshr i32 %blockSize, 2938; CHECK-NEXT:    --> (%blockSize /u 4) U: [0,1073741824) S: [0,1073741824)939; CHECK-NEXT:    %iv = phi i32 [ %dec, %while.body ], [ %shr, %while.body.preheader ]940; CHECK-NEXT:    --> {(%blockSize /u 4),+,-1}<nsw><%while.body> U: [-255,1073741824) S: [-255,1073741824) Exits: 1 LoopDispositions: { %while.body: Computable }941; CHECK-NEXT:    %dec = add i32 %iv, -1942; CHECK-NEXT:    --> {(-1 + (%blockSize /u 4))<nsw>,+,-1}<nsw><%while.body> U: [-256,1073741823) S: [-256,1073741823) Exits: 0 LoopDispositions: { %while.body: Computable }943; CHECK-NEXT:  Determining loop execution counts for: @test_guard_ugt_and_ult944; CHECK-NEXT:  Loop %while.body: backedge-taken count is (-1 + (%blockSize /u 4))<nsw>945; CHECK-NEXT:  Loop %while.body: constant max backedge-taken count is i32 255946; CHECK-NEXT:  Loop %while.body: symbolic max backedge-taken count is (-1 + (%blockSize /u 4))<nsw>947; CHECK-NEXT:  Loop %while.body: Trip multiple is 1948;949  %shr = lshr i32 %blockSize, 2950  %guard1 = icmp ugt i32 %blockSize, 3951  br i1 %guard1, label %while.guard, label %while.end952 953while.guard:954  %guard2 = icmp ult i32 %blockSize, 1025955  br i1 %guard2, label %while.body.preheader, label %while.end956 957while.body.preheader:958  br label %while.body959 960while.body:961  %iv = phi i32 [ %dec, %while.body ], [ %shr, %while.body.preheader ]962  %dec = add i32 %iv, -1963  %cmp.not = icmp eq i32 %dec, 0964  br i1 %cmp.not, label %while.end.loopexit, label %while.body965 966while.end.loopexit:967  br label %while.end968 969while.end:970  ret void971}972 973define void @test_guard_slt_sgt_1(ptr nocapture %a, i64 %N) {974; CHECK-LABEL: 'test_guard_slt_sgt_1'975; CHECK-NEXT:  Classifying expressions for: @test_guard_slt_sgt_1976; CHECK-NEXT:    %and = and i1 %c.0, %c.1977; CHECK-NEXT:    --> (%c.0 umin %c.1) U: full-set S: full-set978; CHECK-NEXT:    %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]979; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,11) S: [0,11) Exits: (-1 + %N) LoopDispositions: { %loop: Computable }980; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %a, i64 %iv981; CHECK-NEXT:    --> {%a,+,4}<nuw><%loop> U: full-set S: full-set Exits: (-4 + (4 * %N) + %a) LoopDispositions: { %loop: Computable }982; CHECK-NEXT:    %iv.next = add nuw nsw i64 %iv, 1983; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,12) S: [1,12) Exits: %N LoopDispositions: { %loop: Computable }984; CHECK-NEXT:  Determining loop execution counts for: @test_guard_slt_sgt_1985; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %N)986; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 10987; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %N)988; CHECK-NEXT:  Loop %loop: Trip multiple is 1989;990entry:991  %c.0 = icmp slt i64 %N, 12992  %c.1 = icmp sgt i64 %N, 0993  %and = and i1 %c.0, %c.1994  br i1 %and, label %loop, label %exit995 996loop:997  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]998  %idx = getelementptr inbounds i32, ptr %a, i64 %iv999  store i32 1, ptr %idx, align 41000  %iv.next = add nuw nsw i64 %iv, 11001  %exitcond = icmp eq i64 %iv.next, %N1002  br i1 %exitcond, label %exit, label %loop1003 1004exit:1005  ret void1006}1007 1008define void @test_guard_slt_sgt_2(ptr nocapture %a, i64 %i) {1009; CHECK-LABEL: 'test_guard_slt_sgt_2'1010; CHECK-NEXT:  Classifying expressions for: @test_guard_slt_sgt_21011; CHECK-NEXT:    %and = and i1 %c.0, %c.11012; CHECK-NEXT:    --> (%c.0 umin %c.1) U: full-set S: full-set1013; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]1014; CHECK-NEXT:    --> {%i,+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 17 LoopDispositions: { %loop: Computable }1015; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %a, i64 %iv1016; CHECK-NEXT:    --> {((4 * %i) + %a),+,4}<%loop> U: full-set S: full-set Exits: (68 + %a) LoopDispositions: { %loop: Computable }1017; CHECK-NEXT:    %iv.next = add nuw nsw i64 %iv, 11018; CHECK-NEXT:    --> {(1 + %i),+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 18 LoopDispositions: { %loop: Computable }1019; CHECK-NEXT:  Determining loop execution counts for: @test_guard_slt_sgt_21020; CHECK-NEXT:  Loop %loop: backedge-taken count is (17 + (-1 * %i))1021; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 121022; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (17 + (-1 * %i))1023; CHECK-NEXT:  Loop %loop: Trip multiple is 11024;1025entry:1026  %c.0 = icmp slt i64 %i, 161027  %c.1 = icmp sgt i64 %i, 41028  %and = and i1 %c.0, %c.11029  br i1 %and, label %loop, label %exit1030 1031loop:1032  %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]1033  %idx = getelementptr inbounds i32, ptr %a, i64 %iv1034  store i32 1, ptr %idx, align 41035  %iv.next = add nuw nsw i64 %iv, 11036  %exitcond = icmp eq i64 %iv.next, 181037  br i1 %exitcond, label %exit, label %loop1038 1039exit:1040  ret void1041}1042 1043define void @test_guard_sle_sge_1(ptr nocapture %a, i64 %N) {1044; CHECK-LABEL: 'test_guard_sle_sge_1'1045; CHECK-NEXT:  Classifying expressions for: @test_guard_sle_sge_11046; CHECK-NEXT:    %and = and i1 %c.0, %c.11047; CHECK-NEXT:    --> (%c.0 umin %c.1) U: full-set S: full-set1048; CHECK-NEXT:    %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]1049; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,12) S: [0,12) Exits: (-1 + %N) LoopDispositions: { %loop: Computable }1050; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %a, i64 %iv1051; CHECK-NEXT:    --> {%a,+,4}<nuw><%loop> U: full-set S: full-set Exits: (-4 + (4 * %N) + %a) LoopDispositions: { %loop: Computable }1052; CHECK-NEXT:    %iv.next = add nuw nsw i64 %iv, 11053; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,13) S: [1,13) Exits: %N LoopDispositions: { %loop: Computable }1054; CHECK-NEXT:  Determining loop execution counts for: @test_guard_sle_sge_11055; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %N)1056; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 111057; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %N)1058; CHECK-NEXT:  Loop %loop: Trip multiple is 11059;1060entry:1061  %c.0 = icmp sle i64 %N, 121062  %c.1 = icmp sge i64 %N, 11063  %and = and i1 %c.0, %c.11064  br i1 %and, label %loop, label %exit1065 1066loop:1067  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]1068  %idx = getelementptr inbounds i32, ptr %a, i64 %iv1069  store i32 1, ptr %idx, align 41070  %iv.next = add nuw nsw i64 %iv, 11071  %exitcond = icmp eq i64 %iv.next, %N1072  br i1 %exitcond, label %exit, label %loop1073 1074exit:1075  ret void1076}1077 1078define void @test_guard_sle_sge_2(ptr nocapture %a, i64 %i) {1079; CHECK-LABEL: 'test_guard_sle_sge_2'1080; CHECK-NEXT:  Classifying expressions for: @test_guard_sle_sge_21081; CHECK-NEXT:    %and = and i1 %c.0, %c.11082; CHECK-NEXT:    --> (%c.0 umin %c.1) U: full-set S: full-set1083; CHECK-NEXT:    %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]1084; CHECK-NEXT:    --> {%i,+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 17 LoopDispositions: { %loop: Computable }1085; CHECK-NEXT:    %idx = getelementptr inbounds i32, ptr %a, i64 %iv1086; CHECK-NEXT:    --> {((4 * %i) + %a),+,4}<%loop> U: full-set S: full-set Exits: (68 + %a) LoopDispositions: { %loop: Computable }1087; CHECK-NEXT:    %iv.next = add nuw nsw i64 %iv, 11088; CHECK-NEXT:    --> {(1 + %i),+,1}<nuw><nsw><%loop> U: full-set S: full-set Exits: 18 LoopDispositions: { %loop: Computable }1089; CHECK-NEXT:  Determining loop execution counts for: @test_guard_sle_sge_21090; CHECK-NEXT:  Loop %loop: backedge-taken count is (17 + (-1 * %i))1091; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 131092; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (17 + (-1 * %i))1093; CHECK-NEXT:  Loop %loop: Trip multiple is 11094;1095entry:1096  %c.0 = icmp sle i64 %i, 161097  %c.1 = icmp sge i64 %i, 41098  %and = and i1 %c.0, %c.11099  br i1 %and, label %loop, label %exit1100 1101loop:1102  %iv = phi i64 [ %iv.next, %loop ], [ %i, %entry ]1103  %idx = getelementptr inbounds i32, ptr %a, i64 %iv1104  store i32 1, ptr %idx, align 41105  %iv.next = add nuw nsw i64 %iv, 11106  %exitcond = icmp eq i64 %iv.next, 181107  br i1 %exitcond, label %exit, label %loop1108 1109exit:1110  ret void1111}1112 1113; The function below uses a single condition to ensure %N > 0 && %N < 8.1114; InstCombine transforms such checks with 2 conditions to a single check as in1115; the test function.1116define void @optimized_range_check_unsigned(ptr %pred, i32 %N) {1117; CHECK-LABEL: 'optimized_range_check_unsigned'1118; CHECK-NEXT:  Classifying expressions for: @optimized_range_check_unsigned1119; CHECK-NEXT:    %N.off = add i32 %N, -11120; CHECK-NEXT:    --> (-1 + %N) U: full-set S: full-set1121; CHECK-NEXT:    %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]1122; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,7) S: [0,7) Exits: (-1 + %N) LoopDispositions: { %loop: Computable }1123; CHECK-NEXT:    %gep = getelementptr inbounds i16, ptr %pred, i32 %iv1124; CHECK-NEXT:    --> {%pred,+,2}<nuw><%loop> U: full-set S: full-set Exits: ((2 * (zext i32 (-1 + %N) to i64))<nuw><nsw> + %pred) LoopDispositions: { %loop: Computable }1125; CHECK-NEXT:    %iv.next = add nuw nsw i32 %iv, 11126; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,8) S: [1,8) Exits: %N LoopDispositions: { %loop: Computable }1127; CHECK-NEXT:  Determining loop execution counts for: @optimized_range_check_unsigned1128; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %N)1129; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 61130; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %N)1131; CHECK-NEXT:  Loop %loop: Trip multiple is 11132;1133entry:1134  %N.off = add i32 %N, -11135  %cmp = icmp ult i32 %N.off, 71136  br i1 %cmp, label %loop, label %exit1137 1138loop:1139  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]1140  %gep = getelementptr inbounds i16, ptr %pred, i32 %iv1141  store i16 0, ptr %gep, align 21142  %iv.next = add nuw nsw i32 %iv, 11143  %ec = icmp eq i32 %iv.next, %N1144  br i1 %ec, label %exit, label %loop1145 1146exit:1147  ret void1148}1149 1150; Same as @optimized_range_check_unsigned, but with the icmp operands swapped.1151define void @optimized_range_check_unsigned_icmp_ops_swapped(ptr %pred, i32 %N) {1152; CHECK-LABEL: 'optimized_range_check_unsigned_icmp_ops_swapped'1153; CHECK-NEXT:  Classifying expressions for: @optimized_range_check_unsigned_icmp_ops_swapped1154; CHECK-NEXT:    %N.off = add i32 %N, -11155; CHECK-NEXT:    --> (-1 + %N) U: full-set S: full-set1156; CHECK-NEXT:    %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]1157; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,7) S: [0,7) Exits: (-1 + %N) LoopDispositions: { %loop: Computable }1158; CHECK-NEXT:    %gep = getelementptr inbounds i16, ptr %pred, i32 %iv1159; CHECK-NEXT:    --> {%pred,+,2}<nuw><%loop> U: full-set S: full-set Exits: ((2 * (zext i32 (-1 + %N) to i64))<nuw><nsw> + %pred) LoopDispositions: { %loop: Computable }1160; CHECK-NEXT:    %iv.next = add nuw nsw i32 %iv, 11161; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,8) S: [1,8) Exits: %N LoopDispositions: { %loop: Computable }1162; CHECK-NEXT:  Determining loop execution counts for: @optimized_range_check_unsigned_icmp_ops_swapped1163; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %N)1164; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 61165; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %N)1166; CHECK-NEXT:  Loop %loop: Trip multiple is 11167;1168entry:1169  %N.off = add i32 %N, -11170  %cmp = icmp ugt i32 7, %N.off1171  br i1 %cmp, label %loop, label %exit1172 1173loop:1174  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]1175  %gep = getelementptr inbounds i16, ptr %pred, i32 %iv1176  store i16 0, ptr %gep, align 21177  %iv.next = add nuw nsw i32 %iv, 11178  %ec = icmp eq i32 %iv.next, %N1179  br i1 %ec, label %exit, label %loop1180 1181exit:1182  ret void1183}1184 1185; The function below uses a single condition to ensure %N > 2 && %N < 22.1186; InstCombine transforms such checks with 2 conditions to a single check as in1187; the test function.1188define void @optimized_range_check_unsigned2(ptr %pred, i32 %N) {1189; CHECK-LABEL: 'optimized_range_check_unsigned2'1190; CHECK-NEXT:  Classifying expressions for: @optimized_range_check_unsigned21191; CHECK-NEXT:    %N.off = add i32 %N, -21192; CHECK-NEXT:    --> (-2 + %N) U: full-set S: full-set1193; CHECK-NEXT:    %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]1194; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,21) S: [0,21) Exits: (-1 + %N) LoopDispositions: { %loop: Computable }1195; CHECK-NEXT:    %gep = getelementptr inbounds i16, ptr %pred, i32 %iv1196; CHECK-NEXT:    --> {%pred,+,2}<nuw><%loop> U: full-set S: full-set Exits: ((2 * (zext i32 (-1 + %N) to i64))<nuw><nsw> + %pred) LoopDispositions: { %loop: Computable }1197; CHECK-NEXT:    %iv.next = add nuw nsw i32 %iv, 11198; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,22) S: [1,22) Exits: %N LoopDispositions: { %loop: Computable }1199; CHECK-NEXT:  Determining loop execution counts for: @optimized_range_check_unsigned21200; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %N)1201; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 201202; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %N)1203; CHECK-NEXT:  Loop %loop: Trip multiple is 11204;1205entry:1206  %N.off = add i32 %N, -21207  %cmp = icmp ult i32 %N.off, 201208  br i1 %cmp, label %loop, label %exit1209 1210loop:1211  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]1212  %gep = getelementptr inbounds i16, ptr %pred, i32 %iv1213  store i16 0, ptr %gep, align 21214  %iv.next = add nuw nsw i32 %iv, 11215  %ec = icmp eq i32 %iv.next, %N1216  br i1 %ec, label %exit, label %loop1217 1218exit:1219  ret void1220}1221 1222; Same as @optimized_range_check_unsigned, but %N already has a range limited1223; to [2,4) beforehand.1224define void @optimized_range_check_unsigned3(ptr %pred, i1 %c) {1225; CHECK-LABEL: 'optimized_range_check_unsigned3'1226; CHECK-NEXT:  Classifying expressions for: @optimized_range_check_unsigned31227; CHECK-NEXT:    %N = select i1 %c, i32 2, i32 31228; CHECK-NEXT:    --> %N U: [2,4) S: [2,4)1229; CHECK-NEXT:    %N.off = add i32 %N, -11230; CHECK-NEXT:    --> (-1 + %N)<nsw> U: [1,3) S: [1,3)1231; CHECK-NEXT:    %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]1232; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,3) S: [0,3) Exits: (-1 + %N)<nsw> LoopDispositions: { %loop: Computable }1233; CHECK-NEXT:    %gep = getelementptr inbounds i16, ptr %pred, i32 %iv1234; CHECK-NEXT:    --> {%pred,+,2}<nuw><%loop> U: full-set S: full-set Exits: ((zext i32 (-2 + (2 * %N)<nuw><nsw>)<nsw> to i64) + %pred) LoopDispositions: { %loop: Computable }1235; CHECK-NEXT:    %iv.next = add nuw nsw i32 %iv, 11236; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,4) S: [1,4) Exits: %N LoopDispositions: { %loop: Computable }1237; CHECK-NEXT:  Determining loop execution counts for: @optimized_range_check_unsigned31238; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %N)<nsw>1239; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 21240; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %N)<nsw>1241; CHECK-NEXT:  Loop %loop: Trip multiple is 11242;1243entry:1244  %N = select i1 %c, i32 2, i32 31245  %N.off = add i32 %N, -11246  %cmp = icmp ult i32 %N.off, 71247  br i1 %cmp, label %loop, label %exit1248 1249loop:1250  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]1251  %gep = getelementptr inbounds i16, ptr %pred, i32 %iv1252  store i16 0, ptr %gep, align 21253  %iv.next = add nuw nsw i32 %iv, 11254  %ec = icmp eq i32 %iv.next, %N1255  br i1 %ec, label %exit, label %loop1256 1257exit:1258  ret void1259}1260 1261; Similar to @optimized_range_check_unsigned, but the initial compare checks1262; against unsigned max (-1), which breaks the range check idiom.1263define void @not_optimized_range_check_unsigned1(ptr %pred, i32 %N) {1264; CHECK-LABEL: 'not_optimized_range_check_unsigned1'1265; CHECK-NEXT:  Classifying expressions for: @not_optimized_range_check_unsigned11266; CHECK-NEXT:    %N.off = add i32 %N, -11267; CHECK-NEXT:    --> (-1 + %N) U: full-set S: full-set1268; CHECK-NEXT:    %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]1269; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %N) LoopDispositions: { %loop: Computable }1270; CHECK-NEXT:    %gep = getelementptr inbounds i16, ptr %pred, i32 %iv1271; CHECK-NEXT:    --> {%pred,+,2}<nuw><%loop> U: full-set S: full-set Exits: ((2 * (zext i32 (-1 + %N) to i64))<nuw><nsw> + %pred) LoopDispositions: { %loop: Computable }1272; CHECK-NEXT:    %iv.next = add nuw nsw i32 %iv, 11273; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: %N LoopDispositions: { %loop: Computable }1274; CHECK-NEXT:  Determining loop execution counts for: @not_optimized_range_check_unsigned11275; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %N)1276; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 -21277; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %N)1278; CHECK-NEXT:  Loop %loop: Trip multiple is 11279;1280entry:1281  %N.off = add i32 %N, -11282  %cmp = icmp ult i32 %N.off, -11283  br i1 %cmp, label %loop, label %exit1284 1285loop:1286  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]1287  %gep = getelementptr inbounds i16, ptr %pred, i32 %iv1288  store i16 0, ptr %gep, align 21289  %iv.next = add nuw nsw i32 %iv, 11290  %ec = icmp eq i32 %iv.next, %N1291  br i1 %ec, label %exit, label %loop1292 1293exit:1294  ret void1295}1296 1297; Similar to @optimized_range_check_unsigned, but the initial compare checks1298; against 0, which breaks the range check idiom.1299define void @not_optimized_range_check_unsigned2(ptr %pred, i32 %N) {1300; CHECK-LABEL: 'not_optimized_range_check_unsigned2'1301; CHECK-NEXT:  Classifying expressions for: @not_optimized_range_check_unsigned21302; CHECK-NEXT:    %N.off = add i32 %N, -11303; CHECK-NEXT:    --> (-1 + %N) U: full-set S: full-set1304; CHECK-NEXT:    %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]1305; CHECK-NEXT:    --> {0,+,1}<nuw><nsw><%loop> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %N) LoopDispositions: { %loop: Computable }1306; CHECK-NEXT:    %gep = getelementptr inbounds i16, ptr %pred, i32 %iv1307; CHECK-NEXT:    --> {%pred,+,2}<nuw><%loop> U: full-set S: full-set Exits: ((2 * (zext i32 (-1 + %N) to i64))<nuw><nsw> + %pred) LoopDispositions: { %loop: Computable }1308; CHECK-NEXT:    %iv.next = add nuw nsw i32 %iv, 11309; CHECK-NEXT:    --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: %N LoopDispositions: { %loop: Computable }1310; CHECK-NEXT:  Determining loop execution counts for: @not_optimized_range_check_unsigned21311; CHECK-NEXT:  Loop %loop: backedge-taken count is (-1 + %N)1312; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 -21313; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is (-1 + %N)1314; CHECK-NEXT:  Loop %loop: Trip multiple is 11315;1316entry:1317  %N.off = add i32 %N, -11318  %cmp = icmp ult i32 %N.off, 01319  br i1 %cmp, label %loop, label %exit1320 1321loop:1322  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]1323  %gep = getelementptr inbounds i16, ptr %pred, i32 %iv1324  store i16 0, ptr %gep, align 21325  %iv.next = add nuw nsw i32 %iv, 11326  %ec = icmp eq i32 %iv.next, %N1327  br i1 %ec, label %exit, label %loop1328 1329exit:1330  ret void1331}1332 1333define i32 @ptr_induction_ult_1(ptr %a, ptr %b) {1334; CHECK-LABEL: 'ptr_induction_ult_1'1335; CHECK-NEXT:  Classifying expressions for: @ptr_induction_ult_11336; CHECK-NEXT:    %ptr.iv = phi ptr [ %ptr.iv.next, %loop ], [ %a, %entry ]1337; CHECK-NEXT:    --> {%a,+,4}<nw><%loop> U: full-set S: full-set Exits: %a LoopDispositions: { %loop: Computable }1338; CHECK-NEXT:    %ptr.iv.next = getelementptr i32, ptr %ptr.iv, i64 11339; CHECK-NEXT:    --> {(4 + %a),+,4}<nw><%loop> U: full-set S: full-set Exits: (4 + %a) LoopDispositions: { %loop: Computable }1340; CHECK-NEXT:  Determining loop execution counts for: @ptr_induction_ult_11341; CHECK-NEXT:  Loop %loop: backedge-taken count is i64 01342; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 01343; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is i64 01344; CHECK-NEXT:  Loop %loop: Trip multiple is 11345;1346entry:1347  %cmp.6 = icmp ult ptr %a, %b1348  br i1 %cmp.6, label %loop, label %exit1349 1350loop:1351  %ptr.iv = phi ptr [ %ptr.iv.next, %loop ], [ %a, %entry ]1352  %ptr.iv.next = getelementptr i32, ptr %ptr.iv, i64 11353  %exitcond = icmp eq ptr %ptr.iv, %a1354  br i1 %exitcond, label %exit, label %loop1355 1356exit:1357  ret i32 01358}1359 1360define void @ptr_induction_eq_1(ptr %a, ptr %b) {1361; CHECK-LABEL: 'ptr_induction_eq_1'1362; CHECK-NEXT:  Classifying expressions for: @ptr_induction_eq_11363; CHECK-NEXT:    %ptr.iv = phi ptr [ %ptr.iv.next, %loop ], [ %a, %entry ]1364; CHECK-NEXT:    --> {%a,+,8}<nuw><%loop> U: full-set S: full-set Exits: ((8 * ((-8 + (-1 * (ptrtoint ptr %a to i64)) + (ptrtoint ptr %b to i64)) /u 8))<nuw> + %a) LoopDispositions: { %loop: Computable }1365; CHECK-NEXT:    %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81366; CHECK-NEXT:    --> {(8 + %a),+,8}<nuw><%loop> U: full-set S: full-set Exits: (8 + (8 * ((-8 + (-1 * (ptrtoint ptr %a to i64)) + (ptrtoint ptr %b to i64)) /u 8))<nuw> + %a) LoopDispositions: { %loop: Computable }1367; CHECK-NEXT:  Determining loop execution counts for: @ptr_induction_eq_11368; CHECK-NEXT:  Loop %loop: backedge-taken count is ((-8 + (-1 * (ptrtoint ptr %a to i64)) + (ptrtoint ptr %b to i64)) /u 8)1369; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 23058430092136939511370; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is ((-8 + (-1 * (ptrtoint ptr %a to i64)) + (ptrtoint ptr %b to i64)) /u 8)1371; CHECK-NEXT:  Loop %loop: Trip multiple is 11372;1373entry:1374  %cmp = icmp eq ptr %a, %b1375  br i1 %cmp, label %exit, label %loop1376 1377loop:1378  %ptr.iv = phi ptr [ %ptr.iv.next, %loop ], [ %a, %entry ]1379  %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81380  %exitcond = icmp eq ptr %ptr.iv.next, %b1381  br i1 %exitcond, label %exit, label %loop1382 1383exit:1384  ret void1385}1386 1387define void @ptr_induction_eq_2(ptr %a, i64 %n) {1388; CHECK-LABEL: 'ptr_induction_eq_2'1389; CHECK-NEXT:  Classifying expressions for: @ptr_induction_eq_21390; CHECK-NEXT:    %b = getelementptr inbounds ptr, ptr %a, i64 %n1391; CHECK-NEXT:    --> ((8 * %n)<nsw> + %a) U: full-set S: full-set1392; CHECK-NEXT:    %ptr.iv = phi ptr [ %ptr.iv.next, %loop ], [ %a, %entry ]1393; CHECK-NEXT:    --> {%a,+,8}<nuw><%loop> U: full-set S: full-set Exits: (-8 + (8 * %n)<nsw> + %a) LoopDispositions: { %loop: Computable }1394; CHECK-NEXT:    %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81395; CHECK-NEXT:    --> {(8 + %a),+,8}<nuw><%loop> U: full-set S: full-set Exits: ((8 * %n)<nsw> + %a) LoopDispositions: { %loop: Computable }1396; CHECK-NEXT:  Determining loop execution counts for: @ptr_induction_eq_21397; CHECK-NEXT:  Loop %loop: backedge-taken count is ((-8 + (8 * %n)<nsw>) /u 8)1398; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 23058430092136939511399; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is ((-8 + (8 * %n)<nsw>) /u 8)1400; CHECK-NEXT:  Loop %loop: Trip multiple is 11401;1402entry:1403  %b = getelementptr inbounds ptr, ptr %a, i64 %n1404  %cmp = icmp eq ptr %a, %b1405  br i1 %cmp, label %exit, label %loop1406 1407loop:1408  %ptr.iv = phi ptr [ %ptr.iv.next, %loop ], [ %a, %entry ]1409  %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81410  %exitcond = icmp eq ptr %ptr.iv.next, %b1411  br i1 %exitcond, label %exit, label %loop1412 1413exit:1414  ret void1415}1416 1417define void @ptr_induction_early_exit_eq_1_with_align_on_load(ptr %a, ptr %b, ptr %c) {1418; CHECK-LABEL: 'ptr_induction_early_exit_eq_1_with_align_on_load'1419; CHECK-NEXT:  Classifying expressions for: @ptr_induction_early_exit_eq_1_with_align_on_load1420; CHECK-NEXT:    %a_ = load ptr, ptr %a, align 8, !align !01421; CHECK-NEXT:    --> %a_ U: [0,-7) S: [-9223372036854775808,9223372036854775801)1422; CHECK-NEXT:    %b_ = load ptr, ptr %b, align 8, !align !01423; CHECK-NEXT:    --> %b_ U: [0,-7) S: [-9223372036854775808,9223372036854775801)1424; CHECK-NEXT:    %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a_, %entry ]1425; CHECK-NEXT:    --> {%a_,+,8}<nuw><%loop> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }1426; CHECK-NEXT:    %ld1 = load ptr, ptr %ptr.iv, align 81427; CHECK-NEXT:    --> %ld1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }1428; CHECK-NEXT:    %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81429; CHECK-NEXT:    --> {(8 + %a_),+,8}<nw><%loop> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }1430; CHECK-NEXT:  Determining loop execution counts for: @ptr_induction_early_exit_eq_1_with_align_on_load1431; CHECK-NEXT:  Loop %loop: <multiple exits> Unpredictable backedge-taken count.1432; CHECK-NEXT:    exit count for loop: ***COULDNOTCOMPUTE***1433; CHECK-NEXT:    exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)1434; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 23058430092136939501435; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)1436; CHECK-NEXT:    symbolic max exit count for loop: ***COULDNOTCOMPUTE***1437; CHECK-NEXT:    symbolic max exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)1438;1439entry:1440  %a_ = load ptr, ptr %a, !align !{i64 8}1441  %b_ = load ptr, ptr %b, !align !{i64 8}1442  %cmp = icmp eq ptr %a_, %b_1443  br i1 %cmp, label %exit, label %loop1444 1445loop:1446  %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a_, %entry ]1447  %ld1 = load ptr, ptr %ptr.iv, align 81448  %earlyexitcond = icmp eq ptr %ld1, %c1449  br i1 %earlyexitcond, label %exit, label %loop.inc1450 1451loop.inc:1452  %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81453  %exitcond = icmp eq ptr %ptr.iv.next, %b_1454  br i1 %exitcond, label %exit, label %loop1455 1456exit:1457  ret void1458}1459 1460define void @ptr_induction_early_exit_eq_1_with_align_on_arguments(ptr align 8 %a, ptr align 8 %b, ptr %c) {1461; CHECK-LABEL: 'ptr_induction_early_exit_eq_1_with_align_on_arguments'1462; CHECK-NEXT:  Classifying expressions for: @ptr_induction_early_exit_eq_1_with_align_on_arguments1463; CHECK-NEXT:    %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a, %entry ]1464; CHECK-NEXT:    --> {%a,+,8}<nuw><%loop> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }1465; CHECK-NEXT:    %ld1 = load ptr, ptr %ptr.iv, align 81466; CHECK-NEXT:    --> %ld1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }1467; CHECK-NEXT:    %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81468; CHECK-NEXT:    --> {(8 + %a),+,8}<nw><%loop> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }1469; CHECK-NEXT:  Determining loop execution counts for: @ptr_induction_early_exit_eq_1_with_align_on_arguments1470; CHECK-NEXT:  Loop %loop: <multiple exits> Unpredictable backedge-taken count.1471; CHECK-NEXT:    exit count for loop: ***COULDNOTCOMPUTE***1472; CHECK-NEXT:    exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a to i64)) + (ptrtoint ptr %b to i64)) /u 8)1473; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 23058430092136939501474; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is ((-8 + (-1 * (ptrtoint ptr %a to i64)) + (ptrtoint ptr %b to i64)) /u 8)1475; CHECK-NEXT:    symbolic max exit count for loop: ***COULDNOTCOMPUTE***1476; CHECK-NEXT:    symbolic max exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a to i64)) + (ptrtoint ptr %b to i64)) /u 8)1477;1478entry:1479  %cmp = icmp eq ptr %a, %b1480  br i1 %cmp, label %exit, label %loop1481 1482loop:1483  %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a, %entry ]1484  %ld1 = load ptr, ptr %ptr.iv, align 81485  %earlyexitcond = icmp eq ptr %ld1, %c1486  br i1 %earlyexitcond, label %exit, label %loop.inc1487 1488loop.inc:1489  %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81490  %exitcond = icmp eq ptr %ptr.iv.next, %b1491  br i1 %exitcond, label %exit, label %loop1492 1493exit:1494  ret void1495}1496 1497define void @ptr_induction_early_exit_eq_1_align_assumption_1(ptr %a, ptr %b, ptr %c) {1498; CHECK-LABEL: 'ptr_induction_early_exit_eq_1_align_assumption_1'1499; CHECK-NEXT:  Classifying expressions for: @ptr_induction_early_exit_eq_1_align_assumption_11500; CHECK-NEXT:    %a_ = load ptr, ptr %a, align 81501; CHECK-NEXT:    --> %a_ U: [0,-7) S: [-9223372036854775808,9223372036854775801)1502; CHECK-NEXT:    %b_ = load ptr, ptr %b, align 81503; CHECK-NEXT:    --> %b_ U: [0,-7) S: [-9223372036854775808,9223372036854775801)1504; CHECK-NEXT:    %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a_, %entry ]1505; CHECK-NEXT:    --> {%a_,+,8}<nuw><%loop> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }1506; CHECK-NEXT:    %ld1 = load ptr, ptr %ptr.iv, align 81507; CHECK-NEXT:    --> %ld1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }1508; CHECK-NEXT:    %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81509; CHECK-NEXT:    --> {(8 + %a_),+,8}<nw><%loop> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }1510; CHECK-NEXT:  Determining loop execution counts for: @ptr_induction_early_exit_eq_1_align_assumption_11511; CHECK-NEXT:  Loop %loop: <multiple exits> Unpredictable backedge-taken count.1512; CHECK-NEXT:    exit count for loop: ***COULDNOTCOMPUTE***1513; CHECK-NEXT:    exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)1514; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 23058430092136939501515; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)1516; CHECK-NEXT:    symbolic max exit count for loop: ***COULDNOTCOMPUTE***1517; CHECK-NEXT:    symbolic max exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)1518;1519entry:1520  %a_ = load ptr, ptr %a1521  call void @llvm.assume(i1 true) [ "align"(ptr %a_, i64 8) ]1522  %b_ = load ptr, ptr %b1523  call void @llvm.assume(i1 true) [ "align"(ptr %b_, i64 8) ]1524  %cmp = icmp eq ptr %a_, %b_1525  br i1 %cmp, label %exit, label %loop1526 1527loop:1528  %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a_, %entry ]1529  %ld1 = load ptr, ptr %ptr.iv, align 81530  %earlyexitcond = icmp eq ptr %ld1, %c1531  br i1 %earlyexitcond, label %exit, label %loop.inc1532 1533loop.inc:1534  %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81535  %exitcond = icmp eq ptr %ptr.iv.next, %b_1536  br i1 %exitcond, label %exit, label %loop1537 1538exit:1539  ret void1540}1541 1542define void @ptr_induction_early_exit_eq_1_align_assumption_2(ptr %a, ptr %b, ptr %c) {1543; CHECK-LABEL: 'ptr_induction_early_exit_eq_1_align_assumption_2'1544; CHECK-NEXT:  Classifying expressions for: @ptr_induction_early_exit_eq_1_align_assumption_21545; CHECK-NEXT:    %a_ = load ptr, ptr %a, align 81546; CHECK-NEXT:    --> %a_ U: [0,-7) S: [-9223372036854775808,9223372036854775801)1547; CHECK-NEXT:    %b_ = load ptr, ptr %b, align 81548; CHECK-NEXT:    --> %b_ U: [0,-7) S: [-9223372036854775808,9223372036854775801)1549; CHECK-NEXT:    %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a_, %entry ]1550; CHECK-NEXT:    --> {%a_,+,8}<nuw><%loop> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }1551; CHECK-NEXT:    %ld1 = load ptr, ptr %ptr.iv, align 81552; CHECK-NEXT:    --> %ld1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }1553; CHECK-NEXT:    %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81554; CHECK-NEXT:    --> {(8 + %a_),+,8}<nw><%loop> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }1555; CHECK-NEXT:  Determining loop execution counts for: @ptr_induction_early_exit_eq_1_align_assumption_21556; CHECK-NEXT:  Loop %loop: <multiple exits> Unpredictable backedge-taken count.1557; CHECK-NEXT:    exit count for loop: ***COULDNOTCOMPUTE***1558; CHECK-NEXT:    exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)1559; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 23058430092136939501560; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)1561; CHECK-NEXT:    symbolic max exit count for loop: ***COULDNOTCOMPUTE***1562; CHECK-NEXT:    symbolic max exit count for loop.inc: ((-8 + (-1 * (ptrtoint ptr %a_ to i64)) + (ptrtoint ptr %b_ to i64)) /u 8)1563;1564entry:1565  %a_ = load ptr, ptr %a1566  %b_ = load ptr, ptr %b1567  call void @llvm.assume(i1 true) [ "align"(ptr %a_, i64 8) ]1568  call void @llvm.assume(i1 true) [ "align"(ptr %b_, i64 8) ]1569  %cmp = icmp eq ptr %a_, %b_1570  br i1 %cmp, label %exit, label %loop1571 1572loop:1573  %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a_, %entry ]1574  %ld1 = load ptr, ptr %ptr.iv, align 81575  %earlyexitcond = icmp eq ptr %ld1, %c1576  br i1 %earlyexitcond, label %exit, label %loop.inc1577 1578loop.inc:1579  %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81580  %exitcond = icmp eq ptr %ptr.iv.next, %b_1581  br i1 %exitcond, label %exit, label %loop1582 1583exit:1584  ret void1585}1586 1587define void @ptr_induction_early_exit_eq_2(ptr %a, i64 %n, ptr %c) {1588; CHECK-LABEL: 'ptr_induction_early_exit_eq_2'1589; CHECK-NEXT:  Classifying expressions for: @ptr_induction_early_exit_eq_21590; CHECK-NEXT:    %b = getelementptr inbounds ptr, ptr %a, i64 %n1591; CHECK-NEXT:    --> ((8 * %n)<nsw> + %a) U: full-set S: full-set1592; CHECK-NEXT:    %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a, %entry ]1593; CHECK-NEXT:    --> {%a,+,8}<nuw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }1594; CHECK-NEXT:    %ld1 = load ptr, ptr %ptr.iv, align 81595; CHECK-NEXT:    --> %ld1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }1596; CHECK-NEXT:    %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81597; CHECK-NEXT:    --> {(8 + %a),+,8}<nw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }1598; CHECK-NEXT:  Determining loop execution counts for: @ptr_induction_early_exit_eq_21599; CHECK-NEXT:  Loop %loop: <multiple exits> Unpredictable backedge-taken count.1600; CHECK-NEXT:    exit count for loop: ***COULDNOTCOMPUTE***1601; CHECK-NEXT:    exit count for loop.inc: ((-8 + (8 * %n)<nsw>) /u 8)1602; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i64 23058430092136939511603; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is ((-8 + (8 * %n)<nsw>) /u 8)1604; CHECK-NEXT:    symbolic max exit count for loop: ***COULDNOTCOMPUTE***1605; CHECK-NEXT:    symbolic max exit count for loop.inc: ((-8 + (8 * %n)<nsw>) /u 8)1606;1607entry:1608  %b = getelementptr inbounds ptr, ptr %a, i64 %n1609  %cmp = icmp eq ptr %a, %b1610  br i1 %cmp, label %exit, label %loop1611 1612loop:1613  %ptr.iv = phi ptr [ %ptr.iv.next, %loop.inc ], [ %a, %entry ]1614  %ld1 = load ptr, ptr %ptr.iv, align 81615  %earlyexitcond = icmp eq ptr %ld1, %c1616  br i1 %earlyexitcond, label %exit, label %loop.inc1617 1618loop.inc:1619  %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 81620  %exitcond = icmp eq ptr %ptr.iv.next, %b1621  br i1 %exitcond, label %exit, label %loop1622 1623exit:1624  ret void1625}1626 1627define void @gep_addrec_nw(ptr %a) {1628; CHECK-LABEL: 'gep_addrec_nw'1629; CHECK-NEXT:  Classifying expressions for: @gep_addrec_nw1630; CHECK-NEXT:    %lsr.iv1 = phi ptr [ %uglygep2, %for.body ], [ %a, %entry ]1631; CHECK-NEXT:    --> {%a,+,4}<nw><%for.body> U: full-set S: full-set Exits: (1512 + %a) LoopDispositions: { %for.body: Computable }1632; CHECK-NEXT:    %lsr.iv = phi i64 [ %lsr.iv.next, %for.body ], [ 379, %entry ]1633; CHECK-NEXT:    --> {379,+,-1}<nsw><%for.body> U: [1,380) S: [1,380) Exits: 1 LoopDispositions: { %for.body: Computable }1634; CHECK-NEXT:    %lsr.iv.next = add nsw i64 %lsr.iv, -11635; CHECK-NEXT:    --> {378,+,-1}<nsw><%for.body> U: [0,379) S: [0,379) Exits: 0 LoopDispositions: { %for.body: Computable }1636; CHECK-NEXT:    %uglygep2 = getelementptr i8, ptr %lsr.iv1, i64 41637; CHECK-NEXT:    --> {(4 + %a),+,4}<nw><%for.body> U: full-set S: full-set Exits: (1516 + %a) LoopDispositions: { %for.body: Computable }1638; CHECK-NEXT:  Determining loop execution counts for: @gep_addrec_nw1639; CHECK-NEXT:  Loop %for.body: backedge-taken count is i64 3781640; CHECK-NEXT:  Loop %for.body: constant max backedge-taken count is i64 3781641; CHECK-NEXT:  Loop %for.body: symbolic max backedge-taken count is i64 3781642; CHECK-NEXT:  Loop %for.body: Trip multiple is 3791643;1644entry:1645  br label %for.body1646 1647for.body:                                         ; preds = %for.body, %entry1648  %lsr.iv1 = phi ptr [ %uglygep2, %for.body ], [ %a, %entry ]1649  %lsr.iv = phi i64 [ %lsr.iv.next, %for.body ], [ 379, %entry ]1650  store i32 1, ptr %lsr.iv1, align 41651  %lsr.iv.next = add nsw i64 %lsr.iv, -11652  %uglygep2 = getelementptr i8, ptr %lsr.iv1, i64 41653  %exitcond.not = icmp eq i64 %lsr.iv.next, 01654  br i1 %exitcond.not, label %for.end, label %for.body1655 1656for.end:                                          ; preds = %for.body1657  ret void1658}1659