xref: /llvm-project/llvm/test/Analysis/ScalarEvolution/exit-count-select-safe.ll (revision 16bc24e7be90f32056a1915d8c57adf1478384e0)
16a563e25SRoman Lebedev; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
26a563e25SRoman Lebedev; RUN: opt -disable-output "-passes=print<scalar-evolution>" %s 2>&1 | FileCheck %s
36a563e25SRoman Lebedev
46a563e25SRoman Lebedevdefine i32 @logical_and_2ops(i32 %n, i32 %m) {
56a563e25SRoman Lebedev; CHECK-LABEL: 'logical_and_2ops'
66a563e25SRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @logical_and_2ops
76a563e25SRoman Lebedev; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
876a0abbcSRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %m) LoopDispositions: { %loop: Computable }
96a563e25SRoman Lebedev; CHECK-NEXT:    %i.next = add i32 %i, 1
1076a0abbcSRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %m)) LoopDispositions: { %loop: Computable }
116a563e25SRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p0, i1 %cond_p1, i1 false
12*16bc24e7SRoman Lebedev; CHECK-NEXT:    --> (%cond_p0 umin_seq %cond_p1) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
136a563e25SRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @logical_and_2ops
1476a0abbcSRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %m)
156a563e25SRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
1676a0abbcSRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %m)
1782fb4f4bSRoman Lebedev; CHECK-NEXT:   Predicates:
1882fb4f4bSRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
196a563e25SRoman Lebedev;
206a563e25SRoman Lebedeventry:
216a563e25SRoman Lebedev  br label %loop
226a563e25SRoman Lebedevloop:
236a563e25SRoman Lebedev  %i = phi i32 [0, %entry], [%i.next, %loop]
246a563e25SRoman Lebedev  %i.next = add i32 %i, 1
256a563e25SRoman Lebedev  %cond_p0 = icmp ult i32 %i, %n
266a563e25SRoman Lebedev  %cond_p1 = icmp ult i32 %i, %m
276a563e25SRoman Lebedev  %cond = select i1 %cond_p0, i1 %cond_p1, i1 false
286a563e25SRoman Lebedev  br i1 %cond, label %loop, label %exit
296a563e25SRoman Lebedevexit:
306a563e25SRoman Lebedev  ret i32 %i
316a563e25SRoman Lebedev}
326a563e25SRoman Lebedev
336a563e25SRoman Lebedevdefine i32 @logical_or_2ops(i32 %n, i32 %m) {
346a563e25SRoman Lebedev; CHECK-LABEL: 'logical_or_2ops'
356a563e25SRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @logical_or_2ops
366a563e25SRoman Lebedev; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
3776a0abbcSRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %m) LoopDispositions: { %loop: Computable }
386a563e25SRoman Lebedev; CHECK-NEXT:    %i.next = add i32 %i, 1
3976a0abbcSRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %m)) LoopDispositions: { %loop: Computable }
406a563e25SRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p0, i1 true, i1 %cond_p1
416a563e25SRoman Lebedev; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
426a563e25SRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @logical_or_2ops
4376a0abbcSRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %m)
446a563e25SRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
4576a0abbcSRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %m)
4682fb4f4bSRoman Lebedev; CHECK-NEXT:   Predicates:
4782fb4f4bSRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
486a563e25SRoman Lebedev;
496a563e25SRoman Lebedeventry:
506a563e25SRoman Lebedev  br label %loop
516a563e25SRoman Lebedevloop:
526a563e25SRoman Lebedev  %i = phi i32 [0, %entry], [%i.next, %loop]
536a563e25SRoman Lebedev  %i.next = add i32 %i, 1
546a563e25SRoman Lebedev  %cond_p0 = icmp uge i32 %i, %n
556a563e25SRoman Lebedev  %cond_p1 = icmp uge i32 %i, %m
566a563e25SRoman Lebedev  %cond = select i1 %cond_p0, i1 true, i1 %cond_p1
576a563e25SRoman Lebedev  br i1 %cond, label %exit, label %loop
586a563e25SRoman Lebedevexit:
596a563e25SRoman Lebedev  ret i32 %i
606a563e25SRoman Lebedev}
616a563e25SRoman Lebedev
626a563e25SRoman Lebedevdefine i32 @logical_and_3ops(i32 %n, i32 %m, i32 %k) {
636a563e25SRoman Lebedev; CHECK-LABEL: 'logical_and_3ops'
646a563e25SRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @logical_and_3ops
656a563e25SRoman Lebedev; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
6676a0abbcSRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %m umin_seq %k) LoopDispositions: { %loop: Computable }
676a563e25SRoman Lebedev; CHECK-NEXT:    %i.next = add i32 %i, 1
6876a0abbcSRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %m umin_seq %k)) LoopDispositions: { %loop: Computable }
696a563e25SRoman Lebedev; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 %cond_p1, i1 false
70*16bc24e7SRoman Lebedev; CHECK-NEXT:    --> (%cond_p0 umin_seq %cond_p1) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
716a563e25SRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 %cond_p2, i1 false
72*16bc24e7SRoman Lebedev; CHECK-NEXT:    --> (%cond_p0 umin_seq %cond_p1 umin_seq %cond_p2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
736a563e25SRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @logical_and_3ops
7476a0abbcSRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %m umin_seq %k)
756a563e25SRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
7676a0abbcSRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %m umin_seq %k)
7782fb4f4bSRoman Lebedev; CHECK-NEXT:   Predicates:
7882fb4f4bSRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
796a563e25SRoman Lebedev;
806a563e25SRoman Lebedeventry:
816a563e25SRoman Lebedev  br label %loop
826a563e25SRoman Lebedevloop:
836a563e25SRoman Lebedev  %i = phi i32 [0, %entry], [%i.next, %loop]
846a563e25SRoman Lebedev  %i.next = add i32 %i, 1
856a563e25SRoman Lebedev  %cond_p0 = icmp ult i32 %i, %n
866a563e25SRoman Lebedev  %cond_p1 = icmp ult i32 %i, %m
876a563e25SRoman Lebedev  %cond_p2 = icmp ult i32 %i, %k
886a563e25SRoman Lebedev  %cond_p3 = select i1 %cond_p0, i1 %cond_p1, i1 false
896a563e25SRoman Lebedev  %cond = select i1 %cond_p3, i1 %cond_p2, i1 false
906a563e25SRoman Lebedev  br i1 %cond, label %loop, label %exit
916a563e25SRoman Lebedevexit:
926a563e25SRoman Lebedev  ret i32 %i
936a563e25SRoman Lebedev}
946a563e25SRoman Lebedev
956a563e25SRoman Lebedevdefine i32 @logical_or_3ops(i32 %n, i32 %m, i32 %k) {
966a563e25SRoman Lebedev; CHECK-LABEL: 'logical_or_3ops'
976a563e25SRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops
986a563e25SRoman Lebedev; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
9976a0abbcSRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %m umin_seq %k) LoopDispositions: { %loop: Computable }
1006a563e25SRoman Lebedev; CHECK-NEXT:    %i.next = add i32 %i, 1
10176a0abbcSRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %m umin_seq %k)) LoopDispositions: { %loop: Computable }
1026a563e25SRoman Lebedev; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
1036a563e25SRoman Lebedev; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
1046a563e25SRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
1056a563e25SRoman Lebedev; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
1066a563e25SRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops
10776a0abbcSRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %m umin_seq %k)
1086a563e25SRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
10976a0abbcSRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %m umin_seq %k)
11082fb4f4bSRoman Lebedev; CHECK-NEXT:   Predicates:
11182fb4f4bSRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
1126a563e25SRoman Lebedev;
1136a563e25SRoman Lebedeventry:
1146a563e25SRoman Lebedev  br label %loop
1156a563e25SRoman Lebedevloop:
1166a563e25SRoman Lebedev  %i = phi i32 [0, %entry], [%i.next, %loop]
1176a563e25SRoman Lebedev  %i.next = add i32 %i, 1
1186a563e25SRoman Lebedev  %cond_p0 = icmp uge i32 %i, %n
1196a563e25SRoman Lebedev  %cond_p1 = icmp uge i32 %i, %m
1206a563e25SRoman Lebedev  %cond_p2 = icmp uge i32 %i, %k
1216a563e25SRoman Lebedev  %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
1226a563e25SRoman Lebedev  %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
1236a563e25SRoman Lebedev  br i1 %cond, label %exit, label %loop
1246a563e25SRoman Lebedevexit:
1256a563e25SRoman Lebedev  ret i32 %i
1266a563e25SRoman Lebedev}
127e0772cf0SRoman Lebedev
12836075942SRoman Lebedevdefine i32 @logical_or_3ops_duplicate(i32 %n, i32 %m, i32 %k) {
12936075942SRoman Lebedev; CHECK-LABEL: 'logical_or_3ops_duplicate'
13036075942SRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops_duplicate
13136075942SRoman Lebedev; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
1325e166507SRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %m umin_seq %k) LoopDispositions: { %loop: Computable }
13336075942SRoman Lebedev; CHECK-NEXT:    %i.next = add i32 %i, 1
1345e166507SRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %m umin_seq %k)) LoopDispositions: { %loop: Computable }
13536075942SRoman Lebedev; CHECK-NEXT:    %cond_p4 = select i1 %cond_p0, i1 true, i1 %cond_p1
13636075942SRoman Lebedev; CHECK-NEXT:    --> %cond_p4 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
13736075942SRoman Lebedev; CHECK-NEXT:    %cond_p5 = select i1 %cond_p4, i1 true, i1 %cond_p2
13836075942SRoman Lebedev; CHECK-NEXT:    --> %cond_p5 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
13936075942SRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p5, i1 true, i1 %cond_p3
14036075942SRoman Lebedev; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
14136075942SRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops_duplicate
1425e166507SRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %m umin_seq %k)
14336075942SRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
1445e166507SRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %m umin_seq %k)
14536075942SRoman Lebedev; CHECK-NEXT:   Predicates:
14636075942SRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
14736075942SRoman Lebedev;
14836075942SRoman Lebedeventry:
14936075942SRoman Lebedev  br label %loop
15036075942SRoman Lebedevloop:
15136075942SRoman Lebedev  %i = phi i32 [0, %entry], [%i.next, %loop]
15236075942SRoman Lebedev  %i.next = add i32 %i, 1
15336075942SRoman Lebedev  %cond_p0 = icmp uge i32 %i, %n
15436075942SRoman Lebedev  %cond_p1 = icmp uge i32 %i, %m
15536075942SRoman Lebedev  %cond_p2 = icmp uge i32 %i, %n
15636075942SRoman Lebedev  %cond_p3 = icmp uge i32 %i, %k
15736075942SRoman Lebedev  %cond_p4 = select i1 %cond_p0, i1 true, i1 %cond_p1
15836075942SRoman Lebedev  %cond_p5 = select i1 %cond_p4, i1 true, i1 %cond_p2
15936075942SRoman Lebedev  %cond = select i1 %cond_p5, i1 true, i1 %cond_p3
16036075942SRoman Lebedev  br i1 %cond, label %exit, label %loop
16136075942SRoman Lebedevexit:
16236075942SRoman Lebedev  ret i32 %i
16336075942SRoman Lebedev}
16436075942SRoman Lebedev
165138d5c75SRoman Lebedevdefine i32 @logical_or_3ops_redundant_uminseq_operand(i32 %n, i32 %m, i32 %k) {
166138d5c75SRoman Lebedev; CHECK-LABEL: 'logical_or_3ops_redundant_uminseq_operand'
167138d5c75SRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops_redundant_uminseq_operand
168138d5c75SRoman Lebedev; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
1695ceb070bSRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: ((%n umin %m) umin_seq %k) LoopDispositions: { %loop: Computable }
170138d5c75SRoman Lebedev; CHECK-NEXT:    %i.next = add i32 %i, 1
1715ceb070bSRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + ((%n umin %m) umin_seq %k)) LoopDispositions: { %loop: Computable }
172138d5c75SRoman Lebedev; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
173138d5c75SRoman Lebedev; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
174138d5c75SRoman Lebedev; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
175138d5c75SRoman Lebedev; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
176138d5c75SRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
177138d5c75SRoman Lebedev; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
178138d5c75SRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops_redundant_uminseq_operand
1795ceb070bSRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is ((%n umin %m) umin_seq %k)
180138d5c75SRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
1815ceb070bSRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is ((%n umin %m) umin_seq %k)
182138d5c75SRoman Lebedev; CHECK-NEXT:   Predicates:
183138d5c75SRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
184138d5c75SRoman Lebedev;
185138d5c75SRoman Lebedeventry:
186138d5c75SRoman Lebedev  br label %loop
187138d5c75SRoman Lebedevloop:
188138d5c75SRoman Lebedev  %i = phi i32 [0, %entry], [%i.next, %loop]
189138d5c75SRoman Lebedev  %i.next = add i32 %i, 1
190138d5c75SRoman Lebedev  %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
191138d5c75SRoman Lebedev  %cond_p0 = icmp uge i32 %i, %umin
192138d5c75SRoman Lebedev  %cond_p1 = icmp uge i32 %i, %n
193138d5c75SRoman Lebedev  %cond_p2 = icmp uge i32 %i, %k
194138d5c75SRoman Lebedev  %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
195138d5c75SRoman Lebedev  %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
196138d5c75SRoman Lebedev  br i1 %cond, label %exit, label %loop
197138d5c75SRoman Lebedevexit:
198138d5c75SRoman Lebedev  ret i32 %i
199138d5c75SRoman Lebedev}
200138d5c75SRoman Lebedev
201138d5c75SRoman Lebedevdefine i32 @logical_or_3ops_redundant_umin_operand(i32 %n, i32 %m, i32 %k) {
202138d5c75SRoman Lebedev; CHECK-LABEL: 'logical_or_3ops_redundant_umin_operand'
203138d5c75SRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops_redundant_umin_operand
204138d5c75SRoman Lebedev; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
2055ceb070bSRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %k umin_seq %m) LoopDispositions: { %loop: Computable }
206138d5c75SRoman Lebedev; CHECK-NEXT:    %i.next = add i32 %i, 1
2075ceb070bSRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %k umin_seq %m)) LoopDispositions: { %loop: Computable }
208138d5c75SRoman Lebedev; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
209138d5c75SRoman Lebedev; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
210138d5c75SRoman Lebedev; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
211138d5c75SRoman Lebedev; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
212138d5c75SRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
213138d5c75SRoman Lebedev; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
214138d5c75SRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops_redundant_umin_operand
2155ceb070bSRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %k umin_seq %m)
216138d5c75SRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
2175ceb070bSRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %k umin_seq %m)
218138d5c75SRoman Lebedev; CHECK-NEXT:   Predicates:
219138d5c75SRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
220138d5c75SRoman Lebedev;
221138d5c75SRoman Lebedeventry:
222138d5c75SRoman Lebedev  br label %loop
223138d5c75SRoman Lebedevloop:
224138d5c75SRoman Lebedev  %i = phi i32 [0, %entry], [%i.next, %loop]
225138d5c75SRoman Lebedev  %i.next = add i32 %i, 1
226138d5c75SRoman Lebedev  %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
227138d5c75SRoman Lebedev  %cond_p0 = icmp uge i32 %i, %n
228138d5c75SRoman Lebedev  %cond_p1 = icmp uge i32 %i, %k
229138d5c75SRoman Lebedev  %cond_p2 = icmp uge i32 %i, %umin
230138d5c75SRoman Lebedev  %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
231138d5c75SRoman Lebedev  %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
232138d5c75SRoman Lebedev  br i1 %cond, label %exit, label %loop
233138d5c75SRoman Lebedevexit:
234138d5c75SRoman Lebedev  ret i32 %i
235138d5c75SRoman Lebedev}
236b2be7dcfSRoman Lebedev
237138d5c75SRoman Lebedevdefine i32 @logical_or_4ops_redundant_operand_across_umins(i32 %n, i32 %m, i32 %k, i32 %q) {
238138d5c75SRoman Lebedev; CHECK-LABEL: 'logical_or_4ops_redundant_operand_across_umins'
239138d5c75SRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @logical_or_4ops_redundant_operand_across_umins
240138d5c75SRoman Lebedev; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
2415ceb070bSRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: ((%n umin %m) umin_seq %k umin_seq %q) LoopDispositions: { %loop: Computable }
242138d5c75SRoman Lebedev; CHECK-NEXT:    %i.next = add i32 %i, 1
2435ceb070bSRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + ((%n umin %m) umin_seq %k umin_seq %q)) LoopDispositions: { %loop: Computable }
244138d5c75SRoman Lebedev; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
245138d5c75SRoman Lebedev; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
246138d5c75SRoman Lebedev; CHECK-NEXT:    %umin2 = call i32 @llvm.umin.i32(i32 %n, i32 %q)
247138d5c75SRoman Lebedev; CHECK-NEXT:    --> (%n umin %q) U: full-set S: full-set Exits: (%n umin %q) LoopDispositions: { %loop: Invariant }
248138d5c75SRoman Lebedev; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
249138d5c75SRoman Lebedev; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
250138d5c75SRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
251138d5c75SRoman Lebedev; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
252138d5c75SRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @logical_or_4ops_redundant_operand_across_umins
2535ceb070bSRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is ((%n umin %m) umin_seq %k umin_seq %q)
254138d5c75SRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
2555ceb070bSRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is ((%n umin %m) umin_seq %k umin_seq %q)
256138d5c75SRoman Lebedev; CHECK-NEXT:   Predicates:
257138d5c75SRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
258138d5c75SRoman Lebedev;
259138d5c75SRoman Lebedeventry:
260138d5c75SRoman Lebedev  br label %loop
261138d5c75SRoman Lebedevloop:
262138d5c75SRoman Lebedev  %i = phi i32 [0, %entry], [%i.next, %loop]
263138d5c75SRoman Lebedev  %i.next = add i32 %i, 1
264138d5c75SRoman Lebedev  %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
265138d5c75SRoman Lebedev  %umin2 = call i32 @llvm.umin.i32(i32 %n, i32 %q)
266138d5c75SRoman Lebedev  %cond_p0 = icmp uge i32 %i, %umin
267138d5c75SRoman Lebedev  %cond_p1 = icmp uge i32 %i, %k
268138d5c75SRoman Lebedev  %cond_p2 = icmp uge i32 %i, %umin2
269138d5c75SRoman Lebedev  %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
270138d5c75SRoman Lebedev  %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
271138d5c75SRoman Lebedev  br i1 %cond, label %exit, label %loop
272138d5c75SRoman Lebedevexit:
273138d5c75SRoman Lebedev  ret i32 %i
274138d5c75SRoman Lebedev}
275138d5c75SRoman Lebedev
276b2be7dcfSRoman Lebedevdefine i32 @logical_or_3ops_operand_wise_redundant_umin(i32 %n, i32 %m, i32 %k) {
277b2be7dcfSRoman Lebedev; CHECK-LABEL: 'logical_or_3ops_operand_wise_redundant_umin'
278b2be7dcfSRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops_operand_wise_redundant_umin
279b2be7dcfSRoman Lebedev; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
2805ceb070bSRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: ((%n umin %m) umin_seq %k) LoopDispositions: { %loop: Computable }
281b2be7dcfSRoman Lebedev; CHECK-NEXT:    %i.next = add i32 %i, 1
2825ceb070bSRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + ((%n umin %m) umin_seq %k)) LoopDispositions: { %loop: Computable }
283b2be7dcfSRoman Lebedev; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
284b2be7dcfSRoman Lebedev; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
285b2be7dcfSRoman Lebedev; CHECK-NEXT:    %umin2 = call i32 @llvm.umin.i32(i32 %n, i32 %k)
286b2be7dcfSRoman Lebedev; CHECK-NEXT:    --> (%n umin %k) U: full-set S: full-set Exits: (%n umin %k) LoopDispositions: { %loop: Invariant }
287b2be7dcfSRoman Lebedev; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
288b2be7dcfSRoman Lebedev; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
289b2be7dcfSRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
290b2be7dcfSRoman Lebedev; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
291b2be7dcfSRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops_operand_wise_redundant_umin
2925ceb070bSRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is ((%n umin %m) umin_seq %k)
293b2be7dcfSRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
2945ceb070bSRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is ((%n umin %m) umin_seq %k)
295b2be7dcfSRoman Lebedev; CHECK-NEXT:   Predicates:
296b2be7dcfSRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
297b2be7dcfSRoman Lebedev;
298b2be7dcfSRoman Lebedeventry:
299b2be7dcfSRoman Lebedev  br label %loop
300b2be7dcfSRoman Lebedevloop:
301b2be7dcfSRoman Lebedev  %i = phi i32 [0, %entry], [%i.next, %loop]
302b2be7dcfSRoman Lebedev  %i.next = add i32 %i, 1
303b2be7dcfSRoman Lebedev  %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
304b2be7dcfSRoman Lebedev  %umin2 = call i32 @llvm.umin.i32(i32 %n, i32 %k)
305b2be7dcfSRoman Lebedev  %cond_p0 = icmp uge i32 %i, %umin
306b2be7dcfSRoman Lebedev  %cond_p1 = icmp uge i32 %i, %k
307b2be7dcfSRoman Lebedev  %cond_p2 = icmp uge i32 %i, %umin2
308b2be7dcfSRoman Lebedev  %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
309b2be7dcfSRoman Lebedev  %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
310b2be7dcfSRoman Lebedev  br i1 %cond, label %exit, label %loop
311b2be7dcfSRoman Lebedevexit:
312b2be7dcfSRoman Lebedev  ret i32 %i
313b2be7dcfSRoman Lebedev}
314b2be7dcfSRoman Lebedev
315b2be7dcfSRoman Lebedevdefine i32 @logical_or_3ops_partially_redundant_umin(i32 %n, i32 %m, i32 %k) {
316b2be7dcfSRoman Lebedev; CHECK-LABEL: 'logical_or_3ops_partially_redundant_umin'
317b2be7dcfSRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops_partially_redundant_umin
318b2be7dcfSRoman Lebedev; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
3195ceb070bSRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq (%m umin %k)) LoopDispositions: { %loop: Computable }
320b2be7dcfSRoman Lebedev; CHECK-NEXT:    %i.next = add i32 %i, 1
3215ceb070bSRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq (%m umin %k))) LoopDispositions: { %loop: Computable }
322b2be7dcfSRoman Lebedev; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
323b2be7dcfSRoman Lebedev; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
324b2be7dcfSRoman Lebedev; CHECK-NEXT:    %umin2 = call i32 @llvm.umin.i32(i32 %umin, i32 %k)
325b2be7dcfSRoman Lebedev; CHECK-NEXT:    --> (%n umin %m umin %k) U: full-set S: full-set Exits: (%n umin %m umin %k) LoopDispositions: { %loop: Invariant }
326b2be7dcfSRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p0, i1 true, i1 %cond_p1
327b2be7dcfSRoman Lebedev; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
328b2be7dcfSRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops_partially_redundant_umin
3295ceb070bSRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq (%m umin %k))
330b2be7dcfSRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
3315ceb070bSRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq (%m umin %k))
332b2be7dcfSRoman Lebedev; CHECK-NEXT:   Predicates:
333b2be7dcfSRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
334b2be7dcfSRoman Lebedev;
335b2be7dcfSRoman Lebedeventry:
336b2be7dcfSRoman Lebedev  br label %loop
337b2be7dcfSRoman Lebedevloop:
338b2be7dcfSRoman Lebedev  %i = phi i32 [0, %entry], [%i.next, %loop]
339b2be7dcfSRoman Lebedev  %i.next = add i32 %i, 1
340b2be7dcfSRoman Lebedev  %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
341b2be7dcfSRoman Lebedev  %umin2 = call i32 @llvm.umin.i32(i32 %umin, i32 %k)
342b2be7dcfSRoman Lebedev  %cond_p0 = icmp uge i32 %i, %n
343b2be7dcfSRoman Lebedev  %cond_p1 = icmp uge i32 %i, %umin2
344b2be7dcfSRoman Lebedev  %cond = select i1 %cond_p0, i1 true, i1 %cond_p1
345b2be7dcfSRoman Lebedev  br i1 %cond, label %exit, label %loop
346b2be7dcfSRoman Lebedevexit:
347b2be7dcfSRoman Lebedev  ret i32 %i
348b2be7dcfSRoman Lebedev}
349b2be7dcfSRoman Lebedev
3502c0c6195SRoman Lebedevdefine i32 @logical_or_5ops_redundant_opearand_of_inner_uminseq(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
3512c0c6195SRoman Lebedev; CHECK-LABEL: 'logical_or_5ops_redundant_opearand_of_inner_uminseq'
3522c0c6195SRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @logical_or_5ops_redundant_opearand_of_inner_uminseq
3532c0c6195SRoman Lebedev; CHECK-NEXT:    %first.i = phi i32 [ 0, %entry ], [ %first.i.next, %first.loop ]
3542c0c6195SRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%first.loop> U: full-set S: full-set Exits: (%e umin_seq %d umin_seq %a) LoopDispositions: { %first.loop: Computable }
3552c0c6195SRoman Lebedev; CHECK-NEXT:    %first.i.next = add i32 %first.i, 1
3562c0c6195SRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%first.loop> U: full-set S: full-set Exits: (1 + (%e umin_seq %d umin_seq %a)) LoopDispositions: { %first.loop: Computable }
3572c0c6195SRoman Lebedev; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
3582c0c6195SRoman Lebedev; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %first.loop: Variant }
3592c0c6195SRoman Lebedev; CHECK-NEXT:    %cond_p4 = select i1 %cond_p3, i1 true, i1 %cond_p2
3602c0c6195SRoman Lebedev; CHECK-NEXT:    --> %cond_p4 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %first.loop: Variant }
3612c0c6195SRoman Lebedev; CHECK-NEXT:    %i = phi i32 [ 0, %first.loop.exit ], [ %i.next, %loop ]
362c86a982dSRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%a umin_seq %b umin_seq ((%e umin_seq %d) umin %c)) LoopDispositions: { %loop: Computable }
3632c0c6195SRoman Lebedev; CHECK-NEXT:    %i.next = add i32 %i, 1
364c86a982dSRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%a umin_seq %b umin_seq ((%e umin_seq %d) umin %c))) LoopDispositions: { %loop: Computable }
3652c0c6195SRoman Lebedev; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %c, i32 %d)
3662c0c6195SRoman Lebedev; CHECK-NEXT:    --> (%c umin %d) U: full-set S: full-set Exits: (%c umin %d) LoopDispositions: { %loop: Invariant }
3672c0c6195SRoman Lebedev; CHECK-NEXT:    %umin2 = call i32 @llvm.umin.i32(i32 %umin, i32 %first.i)
3682c0c6195SRoman Lebedev; CHECK-NEXT:    --> ({0,+,1}<%first.loop> umin %c umin %d) U: full-set S: full-set --> ((%e umin_seq %d umin_seq %a) umin %c umin %d) U: full-set S: full-set Exits: ((%e umin_seq %d umin_seq %a) umin %c umin %d) LoopDispositions: { %loop: Invariant }
3692c0c6195SRoman Lebedev; CHECK-NEXT:    %cond_p8 = select i1 %cond_p5, i1 true, i1 %cond_p6
3702c0c6195SRoman Lebedev; CHECK-NEXT:    --> %cond_p8 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
3712c0c6195SRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p8, i1 true, i1 %cond_p7
3722c0c6195SRoman Lebedev; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
3732c0c6195SRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @logical_or_5ops_redundant_opearand_of_inner_uminseq
374c86a982dSRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is (%a umin_seq %b umin_seq ((%e umin_seq %d) umin %c))
3752c0c6195SRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
376c86a982dSRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%a umin_seq %b umin_seq ((%e umin_seq %d) umin %c))
3772c0c6195SRoman Lebedev; CHECK-NEXT:   Predicates:
3782c0c6195SRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
3792c0c6195SRoman Lebedev; CHECK-NEXT:  Loop %first.loop: backedge-taken count is (%e umin_seq %d umin_seq %a)
3802c0c6195SRoman Lebedev; CHECK-NEXT:  Loop %first.loop: max backedge-taken count is -1
3812c0c6195SRoman Lebedev; CHECK-NEXT:  Loop %first.loop: Predicated backedge-taken count is (%e umin_seq %d umin_seq %a)
3822c0c6195SRoman Lebedev; CHECK-NEXT:   Predicates:
3832c0c6195SRoman Lebedev; CHECK:       Loop %first.loop: Trip multiple is 1
3842c0c6195SRoman Lebedev;
3852c0c6195SRoman Lebedeventry:
3862c0c6195SRoman Lebedev  br label %first.loop
3872c0c6195SRoman Lebedevfirst.loop:
3882c0c6195SRoman Lebedev  %first.i = phi i32 [0, %entry], [%first.i.next, %first.loop]
3892c0c6195SRoman Lebedev  %first.i.next = add i32 %first.i, 1
3902c0c6195SRoman Lebedev  %cond_p0 = icmp uge i32 %first.i, %e
3912c0c6195SRoman Lebedev  %cond_p1 = icmp uge i32 %first.i, %d
3922c0c6195SRoman Lebedev  %cond_p2 = icmp uge i32 %first.i, %a
3932c0c6195SRoman Lebedev  %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
3942c0c6195SRoman Lebedev  %cond_p4 = select i1 %cond_p3, i1 true, i1 %cond_p2
3952c0c6195SRoman Lebedev  br i1 %cond_p4, label %first.loop.exit, label %first.loop
3962c0c6195SRoman Lebedevfirst.loop.exit:
3972c0c6195SRoman Lebedev  br label %loop
3982c0c6195SRoman Lebedevloop:
3992c0c6195SRoman Lebedev  %i = phi i32 [0, %first.loop.exit], [%i.next, %loop]
4002c0c6195SRoman Lebedev  %i.next = add i32 %i, 1
4012c0c6195SRoman Lebedev  %umin = call i32 @llvm.umin.i32(i32 %c, i32 %d)
4022c0c6195SRoman Lebedev  %umin2 = call i32 @llvm.umin.i32(i32 %umin, i32 %first.i)
4032c0c6195SRoman Lebedev  %cond_p5 = icmp uge i32 %i, %a
4042c0c6195SRoman Lebedev  %cond_p6 = icmp uge i32 %i, %b
4052c0c6195SRoman Lebedev  %cond_p7 = icmp uge i32 %i, %umin2
4062c0c6195SRoman Lebedev  %cond_p8 = select i1 %cond_p5, i1 true, i1 %cond_p6
4072c0c6195SRoman Lebedev  %cond = select i1 %cond_p8, i1 true, i1 %cond_p7
4082c0c6195SRoman Lebedev  br i1 %cond, label %exit, label %loop
4092c0c6195SRoman Lebedevexit:
4102c0c6195SRoman Lebedev  ret i32 %i
4112c0c6195SRoman Lebedev}
4122c0c6195SRoman Lebedev
413f34742d7SRoman Lebedevdefine i32 @logical_and_2ops_and_constant(i32 %n, i32 %m, i32 %k) {
414f34742d7SRoman Lebedev; CHECK-LABEL: 'logical_and_2ops_and_constant'
415f34742d7SRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @logical_and_2ops_and_constant
416f34742d7SRoman Lebedev; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
4178dcba206SRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: [0,43) S: [0,43) Exits: (42 umin %n) LoopDispositions: { %loop: Computable }
418f34742d7SRoman Lebedev; CHECK-NEXT:    %i.next = add i32 %i, 1
4198dcba206SRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: [1,44) S: [1,44) Exits: (1 + (42 umin %n))<nuw><nsw> LoopDispositions: { %loop: Computable }
420f34742d7SRoman Lebedev; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 42)
421f34742d7SRoman Lebedev; CHECK-NEXT:    --> (42 umin %n) U: [0,43) S: [0,43) Exits: (42 umin %n) LoopDispositions: { %loop: Invariant }
422f34742d7SRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p1, i1 true, i1 %cond_p0
423f34742d7SRoman Lebedev; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
424f34742d7SRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @logical_and_2ops_and_constant
4258dcba206SRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is (42 umin %n)
426f34742d7SRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is 42
4278dcba206SRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (42 umin %n)
428f34742d7SRoman Lebedev; CHECK-NEXT:   Predicates:
429f34742d7SRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
430f34742d7SRoman Lebedev;
431f34742d7SRoman Lebedeventry:
432f34742d7SRoman Lebedev  br label %loop
433f34742d7SRoman Lebedevloop:
434f34742d7SRoman Lebedev  %i = phi i32 [0, %entry], [%i.next, %loop]
435f34742d7SRoman Lebedev  %i.next = add i32 %i, 1
436f34742d7SRoman Lebedev  %umin = call i32 @llvm.umin.i32(i32 %n, i32 42)
437f34742d7SRoman Lebedev  %cond_p0 = icmp uge i32 %i, %umin
438f34742d7SRoman Lebedev  %cond_p1 = icmp uge i32 %i, %n
439f34742d7SRoman Lebedev  %cond = select i1 %cond_p1, i1 true, i1 %cond_p0
440f34742d7SRoman Lebedev  br i1 %cond, label %exit, label %loop
441f34742d7SRoman Lebedevexit:
442f34742d7SRoman Lebedev  ret i32 %i
443f34742d7SRoman Lebedev}
444f34742d7SRoman Lebedev
445e0772cf0SRoman Lebedevdefine i32 @computeSCEVAtScope(i32 %d.0) {
446e0772cf0SRoman Lebedev; CHECK-LABEL: 'computeSCEVAtScope'
447e0772cf0SRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @computeSCEVAtScope
448e0772cf0SRoman Lebedev; CHECK-NEXT:    %d.1 = phi i32 [ %inc, %for.body ], [ %d.0, %for.cond.preheader ]
4495e166507SRoman Lebedev; CHECK-NEXT:    --> {%d.0,+,1}<nsw><%for.cond> U: full-set S: full-set Exits: 0 LoopDispositions: { %for.cond: Computable, %while.cond: Variant }
450e0772cf0SRoman Lebedev; CHECK-NEXT:    %e.1 = phi i32 [ %inc3, %for.body ], [ %d.0, %for.cond.preheader ]
4515e166507SRoman Lebedev; CHECK-NEXT:    --> {%d.0,+,1}<nsw><%for.cond> U: full-set S: full-set Exits: 0 LoopDispositions: { %for.cond: Computable, %while.cond: Variant }
452e0772cf0SRoman Lebedev; CHECK-NEXT:    %0 = select i1 %tobool1, i1 %tobool2, i1 false
453*16bc24e7SRoman Lebedev; CHECK-NEXT:    --> (%tobool1 umin_seq %tobool2) U: full-set S: full-set Exits: false LoopDispositions: { %for.cond: Variant, %while.cond: Variant }
454e0772cf0SRoman Lebedev; CHECK-NEXT:    %inc = add nsw i32 %d.1, 1
4555e166507SRoman Lebedev; CHECK-NEXT:    --> {(1 + %d.0),+,1}<nw><%for.cond> U: full-set S: full-set Exits: 1 LoopDispositions: { %for.cond: Computable, %while.cond: Variant }
456e0772cf0SRoman Lebedev; CHECK-NEXT:    %inc3 = add nsw i32 %e.1, 1
4575e166507SRoman Lebedev; CHECK-NEXT:    --> {(1 + %d.0),+,1}<nw><%for.cond> U: full-set S: full-set Exits: 1 LoopDispositions: { %for.cond: Computable, %while.cond: Variant }
458e0772cf0SRoman Lebedev; CHECK-NEXT:    %f.1 = phi i32 [ %inc8, %for.body5 ], [ 0, %for.cond4.preheader ]
4595e166507SRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%for.cond4> U: [0,1) S: [0,1) Exits: 0 LoopDispositions: { %for.cond4: Computable, %while.cond: Variant }
460e0772cf0SRoman Lebedev; CHECK-NEXT:    %inc8 = add i32 %f.1, 1
4615e166507SRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%for.cond4> U: [1,2) S: [1,2) Exits: 1 LoopDispositions: { %for.cond4: Computable, %while.cond: Variant }
462e0772cf0SRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @computeSCEVAtScope
4635e166507SRoman Lebedev; CHECK-NEXT:  Loop %for.cond: backedge-taken count is (-1 * %d.0)
464e0772cf0SRoman Lebedev; CHECK-NEXT:  Loop %for.cond: max backedge-taken count is -1
4655e166507SRoman Lebedev; CHECK-NEXT:  Loop %for.cond: Predicated backedge-taken count is (-1 * %d.0)
466e0772cf0SRoman Lebedev; CHECK-NEXT:   Predicates:
467e0772cf0SRoman Lebedev; CHECK:       Loop %for.cond: Trip multiple is 1
4685e166507SRoman Lebedev; CHECK-NEXT:  Loop %for.cond4: backedge-taken count is 0
4695e166507SRoman Lebedev; CHECK-NEXT:  Loop %for.cond4: max backedge-taken count is 0
4705e166507SRoman Lebedev; CHECK-NEXT:  Loop %for.cond4: Predicated backedge-taken count is 0
471e0772cf0SRoman Lebedev; CHECK-NEXT:   Predicates:
472e0772cf0SRoman Lebedev; CHECK:       Loop %for.cond4: Trip multiple is 1
473e0772cf0SRoman Lebedev; CHECK-NEXT:  Loop %while.cond: <multiple exits> Unpredictable backedge-taken count.
474e0772cf0SRoman Lebedev; CHECK-NEXT:  Loop %while.cond: Unpredictable max backedge-taken count.
475e0772cf0SRoman Lebedev; CHECK-NEXT:  Loop %while.cond: Unpredictable predicated backedge-taken count.
476e0772cf0SRoman Lebedev;
477e0772cf0SRoman Lebedeventry:
478e0772cf0SRoman Lebedev  br label %while.cond
479e0772cf0SRoman Lebedev
480e0772cf0SRoman Lebedevwhile.cond.loopexit:                              ; preds = %for.cond4
481e0772cf0SRoman Lebedev  br label %while.cond
482e0772cf0SRoman Lebedev
483e0772cf0SRoman Lebedevwhile.cond:                                       ; preds = %while.cond.loopexit, %entry
484e0772cf0SRoman Lebedev  br label %for.cond.preheader
485e0772cf0SRoman Lebedev
486e0772cf0SRoman Lebedevfor.cond.preheader:                               ; preds = %while.cond
487e0772cf0SRoman Lebedev  br label %for.cond
488e0772cf0SRoman Lebedev
489e0772cf0SRoman Lebedevfor.cond:                                         ; preds = %for.body, %for.cond.preheader
490e0772cf0SRoman Lebedev  %d.1 = phi i32 [ %inc, %for.body ], [ %d.0, %for.cond.preheader ]
491e0772cf0SRoman Lebedev  %e.1 = phi i32 [ %inc3, %for.body ], [ %d.0, %for.cond.preheader ]
492e0772cf0SRoman Lebedev  %tobool1 = icmp ne i32 %e.1, 0
493e0772cf0SRoman Lebedev  %tobool2 = icmp ne i32 %d.1, 0
494e0772cf0SRoman Lebedev  %0 = select i1 %tobool1, i1 %tobool2, i1 false
495e0772cf0SRoman Lebedev  br i1 %0, label %for.body, label %for.cond4.preheader
496e0772cf0SRoman Lebedev
497e0772cf0SRoman Lebedevfor.cond4.preheader:                              ; preds = %for.cond
498e0772cf0SRoman Lebedev  br label %for.cond4
499e0772cf0SRoman Lebedev
500e0772cf0SRoman Lebedevfor.body:                                         ; preds = %for.cond
501e0772cf0SRoman Lebedev  %inc = add nsw i32 %d.1, 1
502e0772cf0SRoman Lebedev  %inc3 = add nsw i32 %e.1, 1
503e0772cf0SRoman Lebedev  br label %for.cond
504e0772cf0SRoman Lebedev
505e0772cf0SRoman Lebedevfor.cond4:                                        ; preds = %for.body5, %for.cond4.preheader
506e0772cf0SRoman Lebedev  %f.1 = phi i32 [ %inc8, %for.body5 ], [ 0, %for.cond4.preheader ]
507e0772cf0SRoman Lebedev  %exitcond.not = icmp eq i32 %f.1, %e.1
508e0772cf0SRoman Lebedev  br i1 %exitcond.not, label %while.cond.loopexit, label %for.body5
509e0772cf0SRoman Lebedev
510e0772cf0SRoman Lebedevfor.body5:                                        ; preds = %for.cond4
511e0772cf0SRoman Lebedev  %inc8 = add i32 %f.1, 1
512e0772cf0SRoman Lebedev  br label %for.cond4
513e0772cf0SRoman Lebedev}
514138d5c75SRoman Lebedev
515f14b5751SRoman Lebedevdefine i64 @uminseq_vs_ptrtoint_complexity(i64 %n, i64 %m, i64* %ptr) {
516f14b5751SRoman Lebedev; CHECK-LABEL: 'uminseq_vs_ptrtoint_complexity'
517f14b5751SRoman Lebedev; CHECK-NEXT:  Classifying expressions for: @uminseq_vs_ptrtoint_complexity
518f14b5751SRoman Lebedev; CHECK-NEXT:    %i = phi i64 [ 0, %entry ], [ %i.next, %loop ]
519f14b5751SRoman Lebedev; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %m) LoopDispositions: { %loop: Computable }
520f14b5751SRoman Lebedev; CHECK-NEXT:    %i.next = add i64 %i, 1
521f14b5751SRoman Lebedev; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %m)) LoopDispositions: { %loop: Computable }
522f14b5751SRoman Lebedev; CHECK-NEXT:    %cond = select i1 %cond_p0, i1 %cond_p1, i1 false
523*16bc24e7SRoman Lebedev; CHECK-NEXT:    --> (%cond_p0 umin_seq %cond_p1) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
524f14b5751SRoman Lebedev; CHECK-NEXT:    %ptr.int = ptrtoint i64* %ptr to i64
525f14b5751SRoman Lebedev; CHECK-NEXT:    --> (ptrtoint i64* %ptr to i64) U: full-set S: full-set
526f14b5751SRoman Lebedev; CHECK-NEXT:    %r = add i64 %i, %ptr.int
527993792bdSRoman Lebedev; CHECK-NEXT:    --> {(ptrtoint i64* %ptr to i64),+,1}<%loop> U: full-set S: full-set --> ((%n umin_seq %m) + (ptrtoint i64* %ptr to i64)) U: full-set S: full-set
528f14b5751SRoman Lebedev; CHECK-NEXT:  Determining loop execution counts for: @uminseq_vs_ptrtoint_complexity
529f14b5751SRoman Lebedev; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %m)
530f14b5751SRoman Lebedev; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
531f14b5751SRoman Lebedev; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %m)
532f14b5751SRoman Lebedev; CHECK-NEXT:   Predicates:
533f14b5751SRoman Lebedev; CHECK:       Loop %loop: Trip multiple is 1
534f14b5751SRoman Lebedev;
535f14b5751SRoman Lebedeventry:
536f14b5751SRoman Lebedev  br label %loop
537f14b5751SRoman Lebedevloop:
538f14b5751SRoman Lebedev  %i = phi i64 [0, %entry], [%i.next, %loop]
539f14b5751SRoman Lebedev  %i.next = add i64 %i, 1
540f14b5751SRoman Lebedev  %cond_p0 = icmp ult i64 %i, %n
541f14b5751SRoman Lebedev  %cond_p1 = icmp ult i64 %i, %m
542f14b5751SRoman Lebedev  %cond = select i1 %cond_p0, i1 %cond_p1, i1 false
543f14b5751SRoman Lebedev  br i1 %cond, label %loop, label %exit
544f14b5751SRoman Lebedevexit:
545f14b5751SRoman Lebedev  %ptr.int = ptrtoint i64* %ptr to i64
546f14b5751SRoman Lebedev  %r = add i64 %i, %ptr.int
547f14b5751SRoman Lebedev  ret i64 %r
548f14b5751SRoman Lebedev}
549f14b5751SRoman Lebedev
550138d5c75SRoman Lebedevdeclare i32 @llvm.umin.i32(i32, i32)
551