1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt -S -passes='print<scalar-evolution>' -disable-output < %s 2>&1 | FileCheck %s
4 ; Test non-unit strides in multiple-exit loops, and the interaction with
7 define void @test_preinc_ult(i64 %len) {
8 ; CHECK-LABEL: 'test_preinc_ult'
9 ; CHECK-NEXT: Classifying expressions for: @test_preinc_ult
10 ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
11 ; CHECK-NEXT: --> {0,+,2}<nuw><%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
12 ; CHECK-NEXT: %iv.inc2 = add nuw i64 %iv, 2
13 ; CHECK-NEXT: --> {2,+,2}<nw><%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
14 ; CHECK-NEXT: Determining loop execution counts for: @test_preinc_ult
15 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
16 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
17 ; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
18 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
19 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
20 ; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
21 ; CHECK-NEXT: symbolic max exit count for latch: ***COULDNOTCOMPUTE***
22 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
28 %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
29 %cmp1 = icmp ult i64 %iv, %len
30 br i1 %cmp1, label %latch, label %exit
33 %iv.inc2 = add nuw i64 %iv, 2
34 %cmp2 = icmp ult i64 %iv.inc2, %len
35 br i1 %cmp2, label %loop, label %exit
41 define void @test_postinc_ult(i64 %len) {
42 ; CHECK-LABEL: 'test_postinc_ult'
43 ; CHECK-NEXT: Classifying expressions for: @test_postinc_ult
44 ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
45 ; CHECK-NEXT: --> {0,+,2}<nuw><%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
46 ; CHECK-NEXT: %iv.inc = add nuw i64 %iv, 1
47 ; CHECK-NEXT: --> {1,+,2}<nuw><%loop> U: [1,0) S: [1,0) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
48 ; CHECK-NEXT: %iv.inc2 = add nuw i64 %iv, 2
49 ; CHECK-NEXT: --> {2,+,2}<nw><%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
50 ; CHECK-NEXT: Determining loop execution counts for: @test_postinc_ult
51 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
52 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
53 ; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
54 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
55 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
56 ; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
57 ; CHECK-NEXT: symbolic max exit count for latch: ***COULDNOTCOMPUTE***
58 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
64 %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
65 %iv.inc = add nuw i64 %iv, 1
66 %cmp1 = icmp ult i64 %iv.inc, %len
67 br i1 %cmp1, label %latch, label %exit
70 %iv.inc2 = add nuw i64 %iv, 2
71 %cmp2 = icmp ult i64 %iv.inc2, %len
72 br i1 %cmp2, label %loop, label %exit
78 define void @test_preinc_slt(i64 %len) {
79 ; CHECK-LABEL: 'test_preinc_slt'
80 ; CHECK-NEXT: Classifying expressions for: @test_preinc_slt
81 ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
82 ; CHECK-NEXT: --> {0,+,2}<nuw><nsw><%loop> U: [0,-9223372036854775808) S: [0,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
83 ; CHECK-NEXT: %iv.inc2 = add nsw i64 %iv, 2
84 ; CHECK-NEXT: --> {2,+,2}<nuw><%loop> U: [2,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
85 ; CHECK-NEXT: Determining loop execution counts for: @test_preinc_slt
86 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
87 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
88 ; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
89 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
90 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
91 ; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
92 ; CHECK-NEXT: symbolic max exit count for latch: ***COULDNOTCOMPUTE***
93 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
99 %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
100 %cmp1 = icmp slt i64 %iv, %len
101 br i1 %cmp1, label %latch, label %exit
104 %iv.inc2 = add nsw i64 %iv, 2
105 %cmp2 = icmp slt i64 %iv.inc2, %len
106 br i1 %cmp2, label %loop, label %exit
112 define void @test_postinc_slt(i64 %len) {
113 ; CHECK-LABEL: 'test_postinc_slt'
114 ; CHECK-NEXT: Classifying expressions for: @test_postinc_slt
115 ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
116 ; CHECK-NEXT: --> {0,+,2}<nuw><nsw><%loop> U: [0,-9223372036854775808) S: [0,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
117 ; CHECK-NEXT: %iv.inc = add nsw i64 %iv, 1
118 ; CHECK-NEXT: --> {1,+,2}<nuw><nsw><%loop> U: [1,-9223372036854775808) S: [1,-9223372036854775808) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
119 ; CHECK-NEXT: %iv.inc2 = add nsw i64 %iv, 2
120 ; CHECK-NEXT: --> {2,+,2}<nuw><%loop> U: [2,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
121 ; CHECK-NEXT: Determining loop execution counts for: @test_postinc_slt
122 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
123 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
124 ; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
125 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
126 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
127 ; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
128 ; CHECK-NEXT: symbolic max exit count for latch: ***COULDNOTCOMPUTE***
129 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
135 %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
136 %iv.inc = add nsw i64 %iv, 1
137 %cmp1 = icmp slt i64 %iv.inc, %len
138 br i1 %cmp1, label %latch, label %exit
141 %iv.inc2 = add nsw i64 %iv, 2
142 %cmp2 = icmp slt i64 %iv.inc2, %len
143 br i1 %cmp2, label %loop, label %exit
149 define void @test_preinc_sgt(i64 %lim) {
150 ; CHECK-LABEL: 'test_preinc_sgt'
151 ; CHECK-NEXT: Classifying expressions for: @test_preinc_sgt
152 ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
153 ; CHECK-NEXT: --> {0,+,-2}<nsw><%loop> U: [0,-1) S: [-9223372036854775808,1) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
154 ; CHECK-NEXT: %iv.inc2 = add nsw i64 %iv, -2
155 ; CHECK-NEXT: --> {-2,+,-2}<nw><%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
156 ; CHECK-NEXT: Determining loop execution counts for: @test_preinc_sgt
157 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
158 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
159 ; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
160 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
161 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
162 ; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
163 ; CHECK-NEXT: symbolic max exit count for latch: ***COULDNOTCOMPUTE***
164 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
170 %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
171 %cmp1 = icmp sgt i64 %iv, %lim
172 br i1 %cmp1, label %latch, label %exit
175 %iv.inc2 = add nsw i64 %iv, -2
176 %cmp2 = icmp sgt i64 %iv.inc2, %lim
177 br i1 %cmp2, label %loop, label %exit
183 define void @test_postinc_sgt(i64 %lim) {
184 ; CHECK-LABEL: 'test_postinc_sgt'
185 ; CHECK-NEXT: Classifying expressions for: @test_postinc_sgt
186 ; CHECK-NEXT: %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
187 ; CHECK-NEXT: --> {0,+,-2}<nsw><%loop> U: [0,-1) S: [-9223372036854775808,1) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
188 ; CHECK-NEXT: %iv.inc = add nsw i64 %iv, -1
189 ; CHECK-NEXT: --> {-1,+,-2}<nsw><%loop> U: [-9223372036854775808,0) S: [-9223372036854775808,0) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
190 ; CHECK-NEXT: %iv.inc2 = add nsw i64 %iv, -2
191 ; CHECK-NEXT: --> {-2,+,-2}<nw><%loop> U: [0,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
192 ; CHECK-NEXT: Determining loop execution counts for: @test_postinc_sgt
193 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
194 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
195 ; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
196 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
197 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
198 ; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
199 ; CHECK-NEXT: symbolic max exit count for latch: ***COULDNOTCOMPUTE***
200 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
206 %iv = phi i64 [ 0, %start ], [ %iv.inc2, %latch ]
207 %iv.inc = add nsw i64 %iv, -1
208 %cmp1 = icmp sgt i64 %iv.inc, %lim
209 br i1 %cmp1, label %latch, label %exit
212 %iv.inc2 = add nsw i64 %iv, -2
213 %cmp2 = icmp sgt i64 %iv.inc2, %lim
214 br i1 %cmp2, label %loop, label %exit