1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt < %s -S -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
4 ; copied from flags-from-poison.ll
5 define void @test-add-nuw(ptr %input, i32 %offset, i32 %numIterations) {
6 ; CHECK-LABEL: 'test-add-nuw'
7 ; CHECK-NEXT: Classifying expressions for: @test-add-nuw
8 ; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
9 ; CHECK-NEXT: --> {0,+,1}<nuw><%loop> U: full-set S: full-set Exits: (-1 + %numIterations) LoopDispositions: { %loop: Computable }
10 ; CHECK-NEXT: %nexti = add nuw i32 %i, 1
11 ; CHECK-NEXT: --> {1,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: %numIterations LoopDispositions: { %loop: Computable }
12 ; CHECK-NEXT: %index32 = add nuw i32 %nexti, %offset
13 ; CHECK-NEXT: --> {(1 + %offset)<nuw>,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: (%offset + %numIterations) LoopDispositions: { %loop: Computable }
14 ; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i32 %index32
15 ; CHECK-NEXT: --> ((4 * (sext i32 {(1 + %offset)<nuw>,+,1}<nuw><%loop> to i64))<nsw> + %input) U: full-set S: full-set Exits: ((4 * (sext i32 (%offset + %numIterations) to i64))<nsw> + %input) LoopDispositions: { %loop: Computable }
16 ; CHECK-NEXT: Determining loop execution counts for: @test-add-nuw
17 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %numIterations)
18 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
19 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + %numIterations)
20 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + %numIterations)
21 ; CHECK-NEXT: Predicates:
22 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
27 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
28 %nexti = add nuw i32 %i, 1
29 %index32 = add nuw i32 %nexti, %offset
30 %ptr = getelementptr inbounds float, ptr %input, i32 %index32
31 %f = load float, ptr %ptr, align 4
32 %exitcond = icmp eq i32 %nexti, %numIterations
33 br i1 %exitcond, label %exit, label %loop
39 define void @test-addrec-nuw(ptr %input, i32 %offset, i32 %numIterations) {
40 ; CHECK-LABEL: 'test-addrec-nuw'
41 ; CHECK-NEXT: Classifying expressions for: @test-addrec-nuw
42 ; CHECK-NEXT: %min.10 = select i1 %cmp, i32 %offset, i32 10
43 ; CHECK-NEXT: --> (10 smax %offset) U: [10,-2147483648) S: [10,-2147483648)
44 ; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
45 ; CHECK-NEXT: --> {0,+,1}<nuw><%loop> U: full-set S: full-set Exits: (-1 + %numIterations) LoopDispositions: { %loop: Computable }
46 ; CHECK-NEXT: %nexti = add nuw i32 %i, 1
47 ; CHECK-NEXT: --> {1,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: %numIterations LoopDispositions: { %loop: Computable }
48 ; CHECK-NEXT: %index32 = add nuw i32 %nexti, %min.10
49 ; CHECK-NEXT: --> {(1 + (10 smax %offset))<nuw>,+,1}<nuw><%loop> U: [11,0) S: [11,0) Exits: ((10 smax %offset) + %numIterations) LoopDispositions: { %loop: Computable }
50 ; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i32 %index32
51 ; CHECK-NEXT: --> ((4 * (sext i32 {(1 + (10 smax %offset))<nuw>,+,1}<nuw><%loop> to i64))<nsw> + %input) U: full-set S: full-set Exits: ((4 * (sext i32 ((10 smax %offset) + %numIterations) to i64))<nsw> + %input) LoopDispositions: { %loop: Computable }
52 ; CHECK-NEXT: Determining loop execution counts for: @test-addrec-nuw
53 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %numIterations)
54 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
55 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + %numIterations)
56 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + %numIterations)
57 ; CHECK-NEXT: Predicates:
58 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
61 %cmp = icmp sgt i32 %offset, 10
62 %min.10 = select i1 %cmp, i32 %offset, i32 10
65 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
66 %nexti = add nuw i32 %i, 1
67 %index32 = add nuw i32 %nexti, %min.10
68 %ptr = getelementptr inbounds float, ptr %input, i32 %index32
69 %f = load float, ptr %ptr, align 4
70 %exitcond = icmp eq i32 %nexti, %numIterations
71 br i1 %exitcond, label %exit, label %loop
77 define void @test-addrec-nsw-start-neg-strip-neg(ptr %input, i32 %offset, i32 %numIterations) {
78 ; CHECK-LABEL: 'test-addrec-nsw-start-neg-strip-neg'
79 ; CHECK-NEXT: Classifying expressions for: @test-addrec-nsw-start-neg-strip-neg
80 ; CHECK-NEXT: %max = select i1 %cmp, i32 %offset, i32 -10
81 ; CHECK-NEXT: --> (-10 smin %offset) U: [-2147483648,-9) S: [-2147483648,-9)
82 ; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
83 ; CHECK-NEXT: --> {0,+,-1}<nsw><%loop> U: [-2147483648,1) S: [-2147483648,1) Exits: (1 + %numIterations) LoopDispositions: { %loop: Computable }
84 ; CHECK-NEXT: %nexti = add nsw i32 %i, -1
85 ; CHECK-NEXT: --> {-1,+,-1}<nsw><%loop> U: [-2147483648,0) S: [-2147483648,0) Exits: %numIterations LoopDispositions: { %loop: Computable }
86 ; CHECK-NEXT: %index32 = add nsw i32 %nexti, %max
87 ; CHECK-NEXT: --> {(-1 + (-10 smin %offset))<nsw>,+,-1}<nsw><%loop> U: [-2147483648,-10) S: [-2147483648,-10) Exits: ((-10 smin %offset) + %numIterations) LoopDispositions: { %loop: Computable }
88 ; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i32 %index32
89 ; CHECK-NEXT: --> {(-4 + (4 * (-10 smin (sext i32 %offset to i64)))<nsw> + %input),+,-4}<nw><%loop> U: full-set S: full-set Exits: (-4 + (4 * (-10 smin (sext i32 %offset to i64)))<nsw> + (-4 * (zext i32 (-1 + (-1 * %numIterations)) to i64))<nsw> + %input) LoopDispositions: { %loop: Computable }
90 ; CHECK-NEXT: Determining loop execution counts for: @test-addrec-nsw-start-neg-strip-neg
91 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (-1 * %numIterations))
92 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
93 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + (-1 * %numIterations))
94 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + (-1 * %numIterations))
95 ; CHECK-NEXT: Predicates:
96 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
99 %cmp = icmp slt i32 %offset, -10
100 %max = select i1 %cmp, i32 %offset, i32 -10
103 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
104 %nexti = add nsw i32 %i, -1
105 %index32 = add nsw i32 %nexti, %max
106 %ptr = getelementptr inbounds float, ptr %input, i32 %index32
107 %f = load float, ptr %ptr, align 4
108 %exitcond = icmp eq i32 %nexti, %numIterations
109 br i1 %exitcond, label %exit, label %loop
115 define void @test-addrec-nsw-start-pos-strip-neg(ptr %input, i32 %offset, i32 %numIterations) {
116 ; CHECK-LABEL: 'test-addrec-nsw-start-pos-strip-neg'
117 ; CHECK-NEXT: Classifying expressions for: @test-addrec-nsw-start-pos-strip-neg
118 ; CHECK-NEXT: %max = select i1 %cmp, i32 %offset, i32 10
119 ; CHECK-NEXT: --> (10 smin %offset) U: [-2147483648,11) S: [-2147483648,11)
120 ; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
121 ; CHECK-NEXT: --> {0,+,-1}<nsw><%loop> U: [-2147483648,1) S: [-2147483648,1) Exits: (1 + %numIterations) LoopDispositions: { %loop: Computable }
122 ; CHECK-NEXT: %nexti = add nsw i32 %i, -1
123 ; CHECK-NEXT: --> {-1,+,-1}<nsw><%loop> U: [-2147483648,0) S: [-2147483648,0) Exits: %numIterations LoopDispositions: { %loop: Computable }
124 ; CHECK-NEXT: %index32 = add nsw i32 %nexti, %max
125 ; CHECK-NEXT: --> {(-1 + (10 smin %offset))<nsw>,+,-1}<nsw><%loop> U: [-2147483648,10) S: [-2147483648,10) Exits: ((10 smin %offset) + %numIterations) LoopDispositions: { %loop: Computable }
126 ; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i32 %index32
127 ; CHECK-NEXT: --> {(-4 + (4 * (10 smin (sext i32 %offset to i64)))<nsw> + %input),+,-4}<nw><%loop> U: full-set S: full-set Exits: (-4 + (4 * (10 smin (sext i32 %offset to i64)))<nsw> + (-4 * (zext i32 (-1 + (-1 * %numIterations)) to i64))<nsw> + %input) LoopDispositions: { %loop: Computable }
128 ; CHECK-NEXT: Determining loop execution counts for: @test-addrec-nsw-start-pos-strip-neg
129 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (-1 * %numIterations))
130 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
131 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + (-1 * %numIterations))
132 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + (-1 * %numIterations))
133 ; CHECK-NEXT: Predicates:
134 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
137 %cmp = icmp slt i32 %offset, 10
138 %max = select i1 %cmp, i32 %offset, i32 10
141 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
142 %nexti = add nsw i32 %i, -1
143 %index32 = add nsw i32 %nexti, %max
144 %ptr = getelementptr inbounds float, ptr %input, i32 %index32
145 %f = load float, ptr %ptr, align 4
146 %exitcond = icmp eq i32 %nexti, %numIterations
147 br i1 %exitcond, label %exit, label %loop
153 define void @test-addrec-nsw-start-pos-strip-pos(ptr %input, i32 %offset, i32 %numIterations) {
154 ; CHECK-LABEL: 'test-addrec-nsw-start-pos-strip-pos'
155 ; CHECK-NEXT: Classifying expressions for: @test-addrec-nsw-start-pos-strip-pos
156 ; CHECK-NEXT: %min = select i1 %cmp, i32 %offset, i32 10
157 ; CHECK-NEXT: --> (10 smax %offset) U: [10,-2147483648) S: [10,-2147483648)
158 ; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
159 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %numIterations) LoopDispositions: { %loop: Computable }
160 ; CHECK-NEXT: %nexti = add nsw i32 %i, 1
161 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: %numIterations LoopDispositions: { %loop: Computable }
162 ; CHECK-NEXT: %index32 = add nsw i32 %nexti, %min
163 ; CHECK-NEXT: --> {(1 + (10 smax %offset))<nuw><nsw>,+,1}<nuw><nsw><%loop> U: [11,-2147483648) S: [11,-2147483648) Exits: ((10 smax %offset) + %numIterations) LoopDispositions: { %loop: Computable }
164 ; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i32 %index32
165 ; CHECK-NEXT: --> {(4 + (4 * (zext i32 (10 smax %offset) to i64))<nuw><nsw> + %input)<nuw>,+,4}<nuw><%loop> U: [44,0) S: [44,0) Exits: (4 + (4 * (zext i32 (-1 + %numIterations) to i64))<nuw><nsw> + (4 * (zext i32 (10 smax %offset) to i64))<nuw><nsw> + %input) LoopDispositions: { %loop: Computable }
166 ; CHECK-NEXT: Determining loop execution counts for: @test-addrec-nsw-start-pos-strip-pos
167 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %numIterations)
168 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
169 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + %numIterations)
170 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + %numIterations)
171 ; CHECK-NEXT: Predicates:
172 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
175 %cmp = icmp sgt i32 %offset, 10
176 %min = select i1 %cmp, i32 %offset, i32 10
179 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
180 %nexti = add nsw i32 %i, 1
181 %index32 = add nsw i32 %nexti, %min
182 %ptr = getelementptr inbounds float, ptr %input, i32 %index32
183 %f = load float, ptr %ptr, align 4
184 %exitcond = icmp eq i32 %nexti, %numIterations
185 br i1 %exitcond, label %exit, label %loop
191 define void @test-addrec-nsw-start-neg-strip-pos(ptr %input, i32 %offset, i32 %numIterations) {
192 ; CHECK-LABEL: 'test-addrec-nsw-start-neg-strip-pos'
193 ; CHECK-NEXT: Classifying expressions for: @test-addrec-nsw-start-neg-strip-pos
194 ; CHECK-NEXT: %min = select i1 %cmp, i32 %offset, i32 -10
195 ; CHECK-NEXT: --> (-10 smax %offset) U: [-10,-2147483648) S: [-10,-2147483648)
196 ; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
197 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %numIterations) LoopDispositions: { %loop: Computable }
198 ; CHECK-NEXT: %nexti = add nsw i32 %i, 1
199 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: %numIterations LoopDispositions: { %loop: Computable }
200 ; CHECK-NEXT: %index32 = add nsw i32 %nexti, %min
201 ; CHECK-NEXT: --> {(1 + (-10 smax %offset))<nsw>,+,1}<nsw><%loop> U: [-9,-2147483648) S: [-9,-2147483648) Exits: ((-10 smax %offset) + %numIterations) LoopDispositions: { %loop: Computable }
202 ; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i32 %index32
203 ; CHECK-NEXT: --> {(4 + (4 * (-10 smax (sext i32 %offset to i64)))<nsw> + %input),+,4}<nw><%loop> U: full-set S: full-set Exits: (4 + (4 * (zext i32 (-1 + %numIterations) to i64))<nuw><nsw> + (4 * (-10 smax (sext i32 %offset to i64)))<nsw> + %input) LoopDispositions: { %loop: Computable }
204 ; CHECK-NEXT: Determining loop execution counts for: @test-addrec-nsw-start-neg-strip-pos
205 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %numIterations)
206 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
207 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + %numIterations)
208 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + %numIterations)
209 ; CHECK-NEXT: Predicates:
210 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
213 %cmp = icmp sgt i32 %offset, -10
214 %min = select i1 %cmp, i32 %offset, i32 -10
217 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
218 %nexti = add nsw i32 %i, 1
219 %index32 = add nsw i32 %nexti, %min
220 %ptr = getelementptr inbounds float, ptr %input, i32 %index32
221 %f = load float, ptr %ptr, align 4
222 %exitcond = icmp eq i32 %nexti, %numIterations
223 br i1 %exitcond, label %exit, label %loop