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 i32 -1
19 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + %numIterations)
20 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
25 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
26 %nexti = add nuw i32 %i, 1
27 %index32 = add nuw i32 %nexti, %offset
28 %ptr = getelementptr inbounds float, ptr %input, i32 %index32
29 %f = load float, ptr %ptr, align 4
30 %exitcond = icmp eq i32 %nexti, %numIterations
31 br i1 %exitcond, label %exit, label %loop
37 define void @test-addrec-nuw(ptr %input, i32 %offset, i32 %numIterations) {
38 ; CHECK-LABEL: 'test-addrec-nuw'
39 ; CHECK-NEXT: Classifying expressions for: @test-addrec-nuw
40 ; CHECK-NEXT: %min.10 = select i1 %cmp, i32 %offset, i32 10
41 ; CHECK-NEXT: --> (10 smax %offset) U: [10,-2147483648) S: [10,-2147483648)
42 ; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
43 ; CHECK-NEXT: --> {0,+,1}<nuw><%loop> U: full-set S: full-set Exits: (-1 + %numIterations) LoopDispositions: { %loop: Computable }
44 ; CHECK-NEXT: %nexti = add nuw i32 %i, 1
45 ; CHECK-NEXT: --> {1,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: %numIterations LoopDispositions: { %loop: Computable }
46 ; CHECK-NEXT: %index32 = add nuw i32 %nexti, %min.10
47 ; CHECK-NEXT: --> {(1 + (10 smax %offset))<nuw>,+,1}<nuw><%loop> U: [11,0) S: [11,0) Exits: ((10 smax %offset) + %numIterations) LoopDispositions: { %loop: Computable }
48 ; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i32 %index32
49 ; 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 }
50 ; CHECK-NEXT: Determining loop execution counts for: @test-addrec-nuw
51 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %numIterations)
52 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 -1
53 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + %numIterations)
54 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
57 %cmp = icmp sgt i32 %offset, 10
58 %min.10 = select i1 %cmp, i32 %offset, i32 10
61 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
62 %nexti = add nuw i32 %i, 1
63 %index32 = add nuw i32 %nexti, %min.10
64 %ptr = getelementptr inbounds float, ptr %input, i32 %index32
65 %f = load float, ptr %ptr, align 4
66 %exitcond = icmp eq i32 %nexti, %numIterations
67 br i1 %exitcond, label %exit, label %loop
73 define void @test-addrec-nsw-start-neg-strip-neg(ptr %input, i32 %offset, i32 %numIterations) {
74 ; CHECK-LABEL: 'test-addrec-nsw-start-neg-strip-neg'
75 ; CHECK-NEXT: Classifying expressions for: @test-addrec-nsw-start-neg-strip-neg
76 ; CHECK-NEXT: %max = select i1 %cmp, i32 %offset, i32 -10
77 ; CHECK-NEXT: --> (-10 smin %offset) U: [-2147483648,-9) S: [-2147483648,-9)
78 ; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
79 ; CHECK-NEXT: --> {0,+,-1}<nsw><%loop> U: [-2147483648,1) S: [-2147483648,1) Exits: (1 + %numIterations) LoopDispositions: { %loop: Computable }
80 ; CHECK-NEXT: %nexti = add nsw i32 %i, -1
81 ; CHECK-NEXT: --> {-1,+,-1}<nsw><%loop> U: [-2147483648,0) S: [-2147483648,0) Exits: %numIterations LoopDispositions: { %loop: Computable }
82 ; CHECK-NEXT: %index32 = add nsw i32 %nexti, %max
83 ; CHECK-NEXT: --> {(-1 + (-10 smin %offset))<nsw>,+,-1}<nsw><%loop> U: [-2147483648,-10) S: [-2147483648,-10) Exits: ((-10 smin %offset) + %numIterations) LoopDispositions: { %loop: Computable }
84 ; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i32 %index32
85 ; 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 }
86 ; CHECK-NEXT: Determining loop execution counts for: @test-addrec-nsw-start-neg-strip-neg
87 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (-1 * %numIterations))
88 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 -1
89 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + (-1 * %numIterations))
90 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
93 %cmp = icmp slt i32 %offset, -10
94 %max = select i1 %cmp, i32 %offset, i32 -10
97 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
98 %nexti = add nsw i32 %i, -1
99 %index32 = add nsw i32 %nexti, %max
100 %ptr = getelementptr inbounds float, ptr %input, i32 %index32
101 %f = load float, ptr %ptr, align 4
102 %exitcond = icmp eq i32 %nexti, %numIterations
103 br i1 %exitcond, label %exit, label %loop
109 define void @test-addrec-nsw-start-pos-strip-neg(ptr %input, i32 %offset, i32 %numIterations) {
110 ; CHECK-LABEL: 'test-addrec-nsw-start-pos-strip-neg'
111 ; CHECK-NEXT: Classifying expressions for: @test-addrec-nsw-start-pos-strip-neg
112 ; CHECK-NEXT: %max = select i1 %cmp, i32 %offset, i32 10
113 ; CHECK-NEXT: --> (10 smin %offset) U: [-2147483648,11) S: [-2147483648,11)
114 ; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
115 ; CHECK-NEXT: --> {0,+,-1}<nsw><%loop> U: [-2147483648,1) S: [-2147483648,1) Exits: (1 + %numIterations) LoopDispositions: { %loop: Computable }
116 ; CHECK-NEXT: %nexti = add nsw i32 %i, -1
117 ; CHECK-NEXT: --> {-1,+,-1}<nsw><%loop> U: [-2147483648,0) S: [-2147483648,0) Exits: %numIterations LoopDispositions: { %loop: Computable }
118 ; CHECK-NEXT: %index32 = add nsw i32 %nexti, %max
119 ; CHECK-NEXT: --> {(-1 + (10 smin %offset))<nsw>,+,-1}<nsw><%loop> U: [-2147483648,10) S: [-2147483648,10) Exits: ((10 smin %offset) + %numIterations) LoopDispositions: { %loop: Computable }
120 ; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i32 %index32
121 ; 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 }
122 ; CHECK-NEXT: Determining loop execution counts for: @test-addrec-nsw-start-pos-strip-neg
123 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (-1 * %numIterations))
124 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 -1
125 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + (-1 * %numIterations))
126 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
129 %cmp = icmp slt i32 %offset, 10
130 %max = select i1 %cmp, i32 %offset, i32 10
133 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
134 %nexti = add nsw i32 %i, -1
135 %index32 = add nsw i32 %nexti, %max
136 %ptr = getelementptr inbounds float, ptr %input, i32 %index32
137 %f = load float, ptr %ptr, align 4
138 %exitcond = icmp eq i32 %nexti, %numIterations
139 br i1 %exitcond, label %exit, label %loop
145 define void @test-addrec-nsw-start-pos-strip-pos(ptr %input, i32 %offset, i32 %numIterations) {
146 ; CHECK-LABEL: 'test-addrec-nsw-start-pos-strip-pos'
147 ; CHECK-NEXT: Classifying expressions for: @test-addrec-nsw-start-pos-strip-pos
148 ; CHECK-NEXT: %min = select i1 %cmp, i32 %offset, i32 10
149 ; CHECK-NEXT: --> (10 smax %offset) U: [10,-2147483648) S: [10,-2147483648)
150 ; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
151 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %numIterations) LoopDispositions: { %loop: Computable }
152 ; CHECK-NEXT: %nexti = add nsw i32 %i, 1
153 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: %numIterations LoopDispositions: { %loop: Computable }
154 ; CHECK-NEXT: %index32 = add nsw i32 %nexti, %min
155 ; 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 }
156 ; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i32 %index32
157 ; 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 }
158 ; CHECK-NEXT: Determining loop execution counts for: @test-addrec-nsw-start-pos-strip-pos
159 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %numIterations)
160 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 -1
161 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + %numIterations)
162 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
165 %cmp = icmp sgt i32 %offset, 10
166 %min = select i1 %cmp, i32 %offset, i32 10
169 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
170 %nexti = add nsw i32 %i, 1
171 %index32 = add nsw i32 %nexti, %min
172 %ptr = getelementptr inbounds float, ptr %input, i32 %index32
173 %f = load float, ptr %ptr, align 4
174 %exitcond = icmp eq i32 %nexti, %numIterations
175 br i1 %exitcond, label %exit, label %loop
181 define void @test-addrec-nsw-start-neg-strip-pos(ptr %input, i32 %offset, i32 %numIterations) {
182 ; CHECK-LABEL: 'test-addrec-nsw-start-neg-strip-pos'
183 ; CHECK-NEXT: Classifying expressions for: @test-addrec-nsw-start-neg-strip-pos
184 ; CHECK-NEXT: %min = select i1 %cmp, i32 %offset, i32 -10
185 ; CHECK-NEXT: --> (-10 smax %offset) U: [-10,-2147483648) S: [-10,-2147483648)
186 ; CHECK-NEXT: %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
187 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %numIterations) LoopDispositions: { %loop: Computable }
188 ; CHECK-NEXT: %nexti = add nsw i32 %i, 1
189 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: %numIterations LoopDispositions: { %loop: Computable }
190 ; CHECK-NEXT: %index32 = add nsw i32 %nexti, %min
191 ; CHECK-NEXT: --> {(1 + (-10 smax %offset))<nsw>,+,1}<nsw><%loop> U: [-9,-2147483648) S: [-9,-2147483648) Exits: ((-10 smax %offset) + %numIterations) LoopDispositions: { %loop: Computable }
192 ; CHECK-NEXT: %ptr = getelementptr inbounds float, ptr %input, i32 %index32
193 ; 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 }
194 ; CHECK-NEXT: Determining loop execution counts for: @test-addrec-nsw-start-neg-strip-pos
195 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %numIterations)
196 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 -1
197 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + %numIterations)
198 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
201 %cmp = icmp sgt i32 %offset, -10
202 %min = select i1 %cmp, i32 %offset, i32 -10
205 %i = phi i32 [ %nexti, %loop ], [ 0, %entry ]
206 %nexti = add nsw i32 %i, 1
207 %index32 = add nsw i32 %nexti, %min
208 %ptr = getelementptr inbounds float, ptr %input, i32 %index32
209 %f = load float, ptr %ptr, align 4
210 %exitcond = icmp eq i32 %nexti, %numIterations
211 br i1 %exitcond, label %exit, label %loop