1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s
4 define void @ule_from_zero(i32 %M, i32 %N) {
5 ; CHECK-LABEL: 'ule_from_zero'
6 ; CHECK-NEXT: Determining loop execution counts for: @ule_from_zero
7 ; CHECK-NEXT: Loop %loop: <multiple exits> backedge-taken count is ((zext i32 %N to i64) umin (1 + (zext i32 %M to i64))<nuw><nsw>)
8 ; CHECK-NEXT: exit count for loop: (1 + (zext i32 %M to i64))<nuw><nsw>
9 ; CHECK-NEXT: exit count for latch: %N
10 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 4294967295
11 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((zext i32 %N to i64) umin (1 + (zext i32 %M to i64))<nuw><nsw>)
12 ; CHECK-NEXT: symbolic max exit count for loop: (1 + (zext i32 %M to i64))<nuw><nsw>
13 ; CHECK-NEXT: symbolic max exit count for latch: %N
14 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
20 %iv = phi i32 [ 0, %entry ], [ %iv.next, %latch ]
21 %cmp1 = icmp ule i32 %iv, %M
22 br i1 %cmp1, label %latch, label %exit
25 %iv.next = add nuw i32 %iv, 1
26 %exitcond.not = icmp eq i32 %iv, %N
27 br i1 %exitcond.not, label %exit, label %loop
33 define void @ule_from_one(i32 %M, i32 %N) {
34 ; CHECK-LABEL: 'ule_from_one'
35 ; CHECK-NEXT: Determining loop execution counts for: @ule_from_one
36 ; CHECK-NEXT: Loop %loop: <multiple exits> backedge-taken count is (%M umin_seq (-1 + %N))
37 ; CHECK-NEXT: exit count for loop: %M
38 ; CHECK-NEXT: exit count for latch: (-1 + %N)
39 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 -1
40 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (%M umin_seq (-1 + %N))
41 ; CHECK-NEXT: symbolic max exit count for loop: %M
42 ; CHECK-NEXT: symbolic max exit count for latch: (-1 + %N)
43 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
49 %iv = phi i32 [ 1, %entry ], [ %iv.next, %latch ]
50 %cmp1 = icmp ule i32 %iv, %M
51 br i1 %cmp1, label %latch, label %exit
54 %iv.next = add nuw i32 %iv, 1
55 %exitcond.not = icmp eq i32 %iv, %N
56 br i1 %exitcond.not, label %exit, label %loop
62 define void @ule_from_unknown(i32 %M, i32 %N, i32 %S) {
63 ; CHECK-LABEL: 'ule_from_unknown'
64 ; CHECK-NEXT: Determining loop execution counts for: @ule_from_unknown
65 ; CHECK-NEXT: Loop %loop: <multiple exits> backedge-taken count is (((-1 * (zext i32 %S to i64))<nsw> + ((zext i32 %S to i64) umax (1 + (zext i32 %M to i64))<nuw><nsw>)) umin_seq (zext i32 ((-1 * %S) + %N) to i64))
66 ; CHECK-NEXT: exit count for loop: ((-1 * (zext i32 %S to i64))<nsw> + ((zext i32 %S to i64) umax (1 + (zext i32 %M to i64))<nuw><nsw>))
67 ; CHECK-NEXT: exit count for latch: ((-1 * %S) + %N)
68 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 4294967295
69 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (((-1 * (zext i32 %S to i64))<nsw> + ((zext i32 %S to i64) umax (1 + (zext i32 %M to i64))<nuw><nsw>)) umin_seq (zext i32 ((-1 * %S) + %N) to i64))
70 ; CHECK-NEXT: symbolic max exit count for loop: ((-1 * (zext i32 %S to i64))<nsw> + ((zext i32 %S to i64) umax (1 + (zext i32 %M to i64))<nuw><nsw>))
71 ; CHECK-NEXT: symbolic max exit count for latch: ((-1 * %S) + %N)
72 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
78 %iv = phi i32 [ %S, %entry ], [ %iv.next, %latch ]
79 %cmp1 = icmp ule i32 %iv, %M
80 br i1 %cmp1, label %latch, label %exit
83 %iv.next = add nuw i32 %iv, 1
84 %exitcond.not = icmp eq i32 %iv, %N
85 br i1 %exitcond.not, label %exit, label %loop
91 define void @ule_from_zero_no_nuw(i32 %M, i32 %N) {
92 ; CHECK-LABEL: 'ule_from_zero_no_nuw'
93 ; CHECK-NEXT: Determining loop execution counts for: @ule_from_zero_no_nuw
94 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
95 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
96 ; CHECK-NEXT: exit count for latch: %N
97 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 -1
98 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is %N
99 ; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
100 ; CHECK-NEXT: symbolic max exit count for latch: %N
101 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((zext i32 %N to i64) umin (1 + (zext i32 %M to i64))<nuw><nsw>)
102 ; CHECK-NEXT: Predicates:
103 ; CHECK-NEXT: {0,+,1}<%loop> Added Flags: <nusw>
109 %iv = phi i32 [ 0, %entry ], [ %iv.next, %latch ]
110 %cmp1 = icmp ule i32 %iv, %M
111 br i1 %cmp1, label %latch, label %exit
114 %iv.next = add i32 %iv, 1
115 %exitcond.not = icmp eq i32 %iv, %N
116 br i1 %exitcond.not, label %exit, label %loop
122 define void @sle_from_int_min(i32 %M, i32 %N) {
123 ; CHECK-LABEL: 'sle_from_int_min'
124 ; CHECK-NEXT: Determining loop execution counts for: @sle_from_int_min
125 ; CHECK-NEXT: Loop %loop: <multiple exits> backedge-taken count is ((zext i32 (-2147483648 + %N) to i64) umin (2147483649 + (sext i32 %M to i64))<nsw>)
126 ; CHECK-NEXT: exit count for loop: (2147483649 + (sext i32 %M to i64))<nsw>
127 ; CHECK-NEXT: exit count for latch: (-2147483648 + %N)
128 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 4294967295
129 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((zext i32 (-2147483648 + %N) to i64) umin (2147483649 + (sext i32 %M to i64))<nsw>)
130 ; CHECK-NEXT: symbolic max exit count for loop: (2147483649 + (sext i32 %M to i64))<nsw>
131 ; CHECK-NEXT: symbolic max exit count for latch: (-2147483648 + %N)
132 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
138 %iv = phi i32 [ u0x80000000, %entry ], [ %iv.next, %latch ]
139 %cmp1 = icmp sle i32 %iv, %M
140 br i1 %cmp1, label %latch, label %exit
143 %iv.next = add nsw i32 %iv, 1
144 %exitcond.not = icmp eq i32 %iv, %N
145 br i1 %exitcond.not, label %exit, label %loop
151 define void @sle_from_int_min_plus_one(i32 %M, i32 %N) {
152 ; CHECK-LABEL: 'sle_from_int_min_plus_one'
153 ; CHECK-NEXT: Determining loop execution counts for: @sle_from_int_min_plus_one
154 ; CHECK-NEXT: Loop %loop: <multiple exits> backedge-taken count is ((-2147483648 + %M) umin_seq (2147483647 + %N))
155 ; CHECK-NEXT: exit count for loop: (-2147483648 + %M)
156 ; CHECK-NEXT: exit count for latch: (2147483647 + %N)
157 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 -1
158 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-2147483648 + %M) umin_seq (2147483647 + %N))
159 ; CHECK-NEXT: symbolic max exit count for loop: (-2147483648 + %M)
160 ; CHECK-NEXT: symbolic max exit count for latch: (2147483647 + %N)
161 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
167 %iv = phi i32 [ u0x80000001, %entry ], [ %iv.next, %latch ]
168 %cmp1 = icmp sle i32 %iv, %M
169 br i1 %cmp1, label %latch, label %exit
172 %iv.next = add nsw i32 %iv, 1
173 %exitcond.not = icmp eq i32 %iv, %N
174 br i1 %exitcond.not, label %exit, label %loop
180 define void @sle_from_unknown(i32 %M, i32 %N, i32 %S) {
181 ; CHECK-LABEL: 'sle_from_unknown'
182 ; CHECK-NEXT: Determining loop execution counts for: @sle_from_unknown
183 ; CHECK-NEXT: Loop %loop: <multiple exits> backedge-taken count is (((-1 * (sext i32 %S to i64))<nsw> + ((sext i32 %S to i64) smax (1 + (sext i32 %M to i64))<nsw>)) umin_seq (zext i32 ((-1 * %S) + %N) to i64))
184 ; CHECK-NEXT: exit count for loop: ((-1 * (sext i32 %S to i64))<nsw> + ((sext i32 %S to i64) smax (1 + (sext i32 %M to i64))<nsw>))
185 ; CHECK-NEXT: exit count for latch: ((-1 * %S) + %N)
186 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 4294967295
187 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (((-1 * (sext i32 %S to i64))<nsw> + ((sext i32 %S to i64) smax (1 + (sext i32 %M to i64))<nsw>)) umin_seq (zext i32 ((-1 * %S) + %N) to i64))
188 ; CHECK-NEXT: symbolic max exit count for loop: ((-1 * (sext i32 %S to i64))<nsw> + ((sext i32 %S to i64) smax (1 + (sext i32 %M to i64))<nsw>))
189 ; CHECK-NEXT: symbolic max exit count for latch: ((-1 * %S) + %N)
190 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
196 %iv = phi i32 [ %S, %entry ], [ %iv.next, %latch ]
197 %cmp1 = icmp sle i32 %iv, %M
198 br i1 %cmp1, label %latch, label %exit
201 %iv.next = add nsw i32 %iv, 1
202 %exitcond.not = icmp eq i32 %iv, %N
203 br i1 %exitcond.not, label %exit, label %loop
209 define void @sle_from_int_min_no_nsw(i32 %M, i32 %N) {
210 ; CHECK-LABEL: 'sle_from_int_min_no_nsw'
211 ; CHECK-NEXT: Determining loop execution counts for: @sle_from_int_min_no_nsw
212 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
213 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
214 ; CHECK-NEXT: exit count for latch: (-2147483648 + %N)
215 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 -1
216 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-2147483648 + %N)
217 ; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
218 ; CHECK-NEXT: symbolic max exit count for latch: (-2147483648 + %N)
219 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((zext i32 (-2147483648 + %N) to i64) umin (2147483649 + (sext i32 %M to i64))<nsw>)
220 ; CHECK-NEXT: Predicates:
221 ; CHECK-NEXT: {-2147483648,+,1}<%loop> Added Flags: <nssw>
227 %iv = phi i32 [ u0x80000000, %entry ], [ %iv.next, %latch ]
228 %cmp1 = icmp sle i32 %iv, %M
229 br i1 %cmp1, label %latch, label %exit
232 %iv.next = add i32 %iv, 1
233 %exitcond.not = icmp eq i32 %iv, %N
234 br i1 %exitcond.not, label %exit, label %loop