xref: /llvm-project/llvm/test/Transforms/IndVarSimplify/addrec_no_exec_on_every_iteration.ll (revision 864bb84a427de367528d15270790dd152871daf2)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=indvars -S | FileCheck %s
3
4target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5target triple = "x86_64-unknown-linux-gnu"
6
7; Function Attrs: nofree norecurse nounwind uwtable
8define void @test(ptr nocapture readnone %arg, ptr noalias nocapture readnone %arg1, ptr noalias nocapture readnone %arg2, ptr noalias nocapture readonly %arg3, ptr noalias nocapture readnone %arg4) local_unnamed_addr #0 {
9; CHECK-LABEL: @test
10bb:
11  %tmp5 = load ptr, ptr %arg3, align 8, !invariant.load !0, !dereferenceable !1, !align !2
12  %tmp6 = getelementptr inbounds ptr, ptr %arg3, i64 3
13  %tmp7 = load ptr, ptr %tmp6, align 8, !invariant.load !0, !dereferenceable !3, !align !2
14  br label %bb9
15
16bb9:                                              ; preds = %bb33, %bb
17  %tmp10 = phi i64 [ 0, %bb ], [ %tmp34, %bb33 ]
18  %tmp11 = sub nsw i64 9, %tmp10
19  br label %bb12
20
21bb12:                                             ; preds = %bb30, %bb9
22  %tmp13 = phi i64 [ 0, %bb9 ], [ %tmp31, %bb30 ]
23  %tmp14 = sub nsw i64 4, %tmp13
24  br label %bb15
25
26bb15:                                             ; preds = %bb27, %bb12
27  %tmp16 = phi i64 [ 0, %bb12 ], [ %tmp28, %bb27 ]
28  %tmp17 = mul i64 %tmp16, -2
29  %tmp18 = add i64 %tmp17, 2
30  br label %bb19
31
32bb19:                                             ; preds = %bb19, %bb15
33  %tmp20 = phi i64 [ 0, %bb15 ], [ %tmp25, %bb19 ]
34  %tmp21 = add nuw nsw i64 %tmp18, %tmp20
35  %tmp22 = getelementptr inbounds [1 x [4 x [10 x [5 x float]]]], ptr %tmp5, i64 0, i64 0, i64 %tmp21, i64 %tmp11, i64 %tmp14
36  %tmp23 = load float, ptr %tmp22, align 4, !invariant.load !0, !noalias !4
37  %tmp24 = getelementptr inbounds [10 x [5 x [2 x [1 x [2 x float]]]]], ptr %tmp7, i64 0, i64 %tmp10, i64 %tmp13, i64 %tmp16, i64 0, i64 %tmp20
38  store float %tmp23, ptr %tmp24, align 4, !alias.scope !4, !noalias !7
39  %tmp25 = add nuw nsw i64 %tmp20, 1
40  %tmp26 = icmp eq i64 %tmp20, 0
41  br i1 %tmp26, label %bb19, label %bb27
42
43bb27:                                             ; preds = %bb19
44  %tmp28 = add nuw nsw i64 %tmp16, 1
45  %tmp29 = icmp eq i64 %tmp16, 0
46  br i1 %tmp29, label %bb15, label %bb30
47
48bb30:                                             ; preds = %bb27
49  %tmp31 = add nuw nsw i64 %tmp13, 1
50  %tmp32 = icmp ugt i64 %tmp13, 3
51  br i1 %tmp32, label %bb33, label %bb12
52
53bb33:                                             ; preds = %bb30
54  %tmp34 = add nuw nsw i64 %tmp10, 1
55  %tmp35 = icmp ugt i64 %tmp10, 8
56  br i1 %tmp35, label %bb36, label %bb9
57
58bb36:                                             ; preds = %bb33
59  %tmp37 = getelementptr inbounds ptr, ptr %arg3, i64 1
60  %tmp39 = load ptr, ptr %tmp37, align 8, !invariant.load !0, !dereferenceable !10, !align !2
61  %tmp40 = getelementptr inbounds i8, ptr %tmp7, i64 800
62  br label %bb42
63
64bb42:                                             ; preds = %bb63, %bb36
65  %tmp43 = phi i64 [ 0, %bb36 ], [ %tmp64, %bb63 ]
66  br label %bb44
67
68bb44:                                             ; preds = %bb60, %bb42
69  %tmp45 = phi i64 [ 0, %bb42 ], [ %tmp61, %bb60 ]
70  br label %bb46
71
72bb46:                                             ; preds = %bb57, %bb44
73  %tmp47 = phi i64 [ 0, %bb44 ], [ %tmp58, %bb57 ]
74  br label %bb48
75
76bb48:                                             ; preds = %bb48, %bb46
77  %tmp49 = phi i64 [ 0, %bb46 ], [ %tmp55, %bb48 ]
78  %tmp50 = shl nuw nsw i64 %tmp49, 1
79  %tmp51 = add nuw nsw i64 %tmp50, %tmp43
80  %tmp52 = getelementptr inbounds [1 x [4 x [6 x [7 x float]]]], ptr %tmp39, i64 0, i64 0, i64 %tmp51, i64 %tmp45, i64 %tmp47
81  %tmp53 = load float, ptr %tmp52, align 4, !invariant.load !0, !noalias !11
82  %tmp54 = getelementptr inbounds [2 x [6 x [7 x [2 x [1 x float]]]]], ptr %tmp40, i64 0, i64 %tmp43, i64 %tmp45, i64 %tmp47, i64 %tmp49, i64 0
83  store float %tmp53, ptr %tmp54, align 4, !alias.scope !11, !noalias !12
84  %tmp55 = add nuw nsw i64 %tmp49, 1
85  %tmp56 = icmp eq i64 %tmp49, 0
86  br i1 %tmp56, label %bb48, label %bb57
87
88bb57:                                             ; preds = %bb48
89  %tmp58 = add nuw nsw i64 %tmp47, 1
90  %tmp59 = icmp ugt i64 %tmp47, 5
91  br i1 %tmp59, label %bb60, label %bb46
92
93bb60:                                             ; preds = %bb57
94  %tmp61 = add nuw nsw i64 %tmp45, 1
95  %tmp62 = icmp ugt i64 %tmp45, 4
96  br i1 %tmp62, label %bb63, label %bb44
97
98bb63:                                             ; preds = %bb60
99  %tmp64 = add nuw nsw i64 %tmp43, 1
100  %tmp65 = icmp eq i64 %tmp43, 0
101  br i1 %tmp65, label %bb42, label %bb66
102
103bb66:                                             ; preds = %bb63
104  %tmp67 = getelementptr inbounds i8, ptr %tmp7, i64 1472
105  br label %bb69
106
107bb69:                                             ; preds = %bb140, %bb66
108  %tmp70 = phi i64 [ 0, %bb66 ], [ %tmp141, %bb140 ]
109  br label %bb71
110
111bb71:                                             ; preds = %bb137, %bb69
112  %tmp72 = phi i64 [ 0, %bb69 ], [ %tmp138, %bb137 ]
113  %tmp73 = shl nuw nsw i64 %tmp72, 1
114  %tmp74 = add nsw i64 %tmp73, -2
115  br label %bb75
116
117bb75:                                             ; preds = %bb134, %bb71
118  %tmp76 = phi i64 [ 0, %bb71 ], [ %tmp135, %bb134 ]
119  %tmp77 = add nsw i64 %tmp76, -1
120  br label %bb78
121
122bb78:                                             ; preds = %bb129, %bb75
123  %tmp79 = phi i64 [ 0, %bb75 ], [ %tmp132, %bb129 ]
124  br label %bb80
125
126bb80:                                             ; preds = %bb125, %bb78
127  %tmp81 = phi float [ 0.000000e+00, %bb78 ], [ %tmp126, %bb125 ]
128  %tmp82 = phi i64 [ 0, %bb78 ], [ %tmp127, %bb125 ]
129  %tmp83 = shl nuw nsw i64 %tmp82, 1
130  %tmp84 = add nsw i64 %tmp83, -1
131  %tmp85 = icmp ult i64 %tmp84, 10
132  %tmp86 = sub nsw i64 5, %tmp82
133  br i1 %tmp85, label %bb88, label %bb87
134
135bb87:                                             ; preds = %bb80
136  br label %bb124
137
138bb88:                                             ; preds = %bb80
139  br label %bb89
140
141bb89:                                             ; preds = %bb100, %bb88
142  %tmp90 = phi float [ %tmp101, %bb100 ], [ %tmp81, %bb88 ]
143  %tmp91 = phi i64 [ %tmp102, %bb100 ], [ 0, %bb88 ]
144  %tmp92 = add i64 %tmp74, %tmp91
145  %tmp93 = icmp ult i64 %tmp92, 5
146  %tmp94 = sub nsw i64 6, %tmp91
147  br i1 %tmp93, label %bb96, label %bb95
148
149bb95:                                             ; preds = %bb89
150  br label %bb99
151
152bb96:                                             ; preds = %bb89
153  br label %bb104
154
155bb97:                                             ; preds = %bb110
156  %tmp98 = phi float [ %tmp111, %bb110 ]
157  br label %bb100
158
159bb99:                                             ; preds = %bb95
160  br label %bb100
161
162bb100:                                            ; preds = %bb99, %bb97
163  %tmp101 = phi float [ %tmp98, %bb97 ], [ %tmp90, %bb99 ]
164  %tmp102 = add nuw nsw i64 %tmp91, 1
165  %tmp103 = icmp ugt i64 %tmp91, 5
166  br i1 %tmp103, label %bb122, label %bb89
167
168bb104:                                            ; preds = %bb110, %bb96
169  %tmp105 = phi float [ %tmp111, %bb110 ], [ %tmp90, %bb96 ]
170  %tmp106 = phi i64 [ %tmp112, %bb110 ], [ 0, %bb96 ]
171  %tmp107 = shl nuw nsw i64 %tmp106, 1
172  ; CHECK-NOT: %bugged = add nuw nsw
173  ; CHECK:     %bugged = add nsw
174  %bugged = add i64 %tmp77, %tmp107
175  %tmp109 = icmp ult i64 %bugged, 2
176  br i1 %tmp109, label %bb114, label %bb110
177
178bb110:                                            ; preds = %bb114, %bb104
179  %tmp111 = phi float [ %tmp121, %bb114 ], [ %tmp105, %bb104 ]
180  %tmp112 = add nuw nsw i64 %tmp106, 1
181  %tmp113 = icmp eq i64 %tmp106, 0
182  br i1 %tmp113, label %bb104, label %bb97
183
184bb114:                                            ; preds = %bb104
185  %tmp115 = sub nsw i64 1, %tmp106
186  %tmp116 = getelementptr inbounds [2 x [6 x [7 x [2 x [1 x float]]]]], ptr %tmp40, i64 0, i64 %tmp70, i64 %tmp86, i64 %tmp94, i64 %tmp115, i64 0
187  %tmp117 = getelementptr inbounds [10 x [5 x [2 x [1 x [2 x float]]]]], ptr %tmp7, i64 0, i64 %tmp84, i64 %tmp92, i64 %bugged, i64 0, i64 %tmp79
188  %tmp118 = load float, ptr %tmp117, align 4, !alias.scope !4, !noalias !7
189  %tmp119 = load float, ptr %tmp116, align 4, !alias.scope !11, !noalias !12
190  %tmp120 = fmul reassoc nsz contract float %tmp118, %tmp119
191  %tmp121 = fadd reassoc nsz contract float %tmp105, %tmp120
192  br label %bb110
193
194bb122:                                            ; preds = %bb100
195  %tmp123 = phi float [ %tmp101, %bb100 ]
196  br label %bb125
197
198bb124:                                            ; preds = %bb87
199  br label %bb125
200
201bb125:                                            ; preds = %bb124, %bb122
202  %tmp126 = phi float [ %tmp123, %bb122 ], [ %tmp81, %bb124 ]
203  %tmp127 = add nuw nsw i64 %tmp82, 1
204  %tmp128 = icmp ugt i64 %tmp82, 4
205  br i1 %tmp128, label %bb129, label %bb80
206
207bb129:                                            ; preds = %bb125
208  %tmp130 = phi float [ %tmp126, %bb125 ]
209  %tmp131 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 %tmp70, i64 0, i64 %tmp72, i64 %tmp76, i64 %tmp79
210  store float %tmp130, ptr %tmp131, align 4, !alias.scope !13, !noalias !14
211  %tmp132 = add nuw nsw i64 %tmp79, 1
212  %tmp133 = icmp eq i64 %tmp79, 0
213  br i1 %tmp133, label %bb78, label %bb134
214
215bb134:                                            ; preds = %bb129
216  %tmp135 = add nuw nsw i64 %tmp76, 1
217  %tmp136 = icmp eq i64 %tmp76, 0
218  br i1 %tmp136, label %bb75, label %bb137
219
220bb137:                                            ; preds = %bb134
221  %tmp138 = add nuw nsw i64 %tmp72, 1
222  %tmp139 = icmp eq i64 %tmp72, 0
223  br i1 %tmp139, label %bb71, label %bb140
224
225bb140:                                            ; preds = %bb137
226  %tmp141 = add nuw nsw i64 %tmp70, 1
227  %tmp142 = icmp eq i64 %tmp70, 0
228  br i1 %tmp142, label %bb69, label %bb143
229
230bb143:                                            ; preds = %bb140
231  %tmp144 = getelementptr inbounds ptr, ptr %arg3, i64 2
232  %tmp146 = load ptr, ptr %tmp144, align 8, !invariant.load !0, !dereferenceable !16, !align !2
233  br label %bb147
234
235bb147:                                            ; preds = %bb143
236  br label %bb148
237
238bb148:                                            ; preds = %bb147
239  br label %bb149
240
241bb149:                                            ; preds = %bb148
242  %tmp151 = load float, ptr %tmp67, align 4, !alias.scope !13, !noalias !14
243  store float %tmp151, ptr %tmp146, align 4, !alias.scope !17, !noalias !13
244  %tmp153 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 0, i64 0, i64 1, i64 0, i64 0
245  %tmp154 = load float, ptr %tmp153, align 4, !alias.scope !13, !noalias !14
246  %tmp155 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 0, i64 0, i64 0, i64 1
247  store float %tmp154, ptr %tmp155, align 4, !alias.scope !17, !noalias !13
248  br label %bb156
249
250bb156:                                            ; preds = %bb149
251  %tmp157 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 1, i64 0, i64 0, i64 0, i64 0
252  %tmp158 = load float, ptr %tmp157, align 4, !alias.scope !13, !noalias !14
253  %tmp159 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 0, i64 1, i64 0, i64 0
254  store float %tmp158, ptr %tmp159, align 4, !alias.scope !17, !noalias !13
255  %tmp160 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 1, i64 0, i64 1, i64 0, i64 0
256  %tmp161 = load float, ptr %tmp160, align 4, !alias.scope !13, !noalias !14
257  %tmp162 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 0, i64 1, i64 0, i64 1
258  store float %tmp161, ptr %tmp162, align 4, !alias.scope !17, !noalias !13
259  br label %bb163
260
261bb163:                                            ; preds = %bb156
262  br label %bb164
263
264bb164:                                            ; preds = %bb163
265  %tmp165 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 0, i64 0, i64 0, i64 0, i64 1
266  %tmp166 = load float, ptr %tmp165, align 4, !alias.scope !13, !noalias !14
267  %tmp167 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 1, i64 0, i64 0, i64 0
268  store float %tmp166, ptr %tmp167, align 4, !alias.scope !17, !noalias !13
269  %tmp168 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 0, i64 0, i64 1, i64 0, i64 1
270  %tmp169 = load float, ptr %tmp168, align 4, !alias.scope !13, !noalias !14
271  %tmp170 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 1, i64 0, i64 0, i64 1
272  store float %tmp169, ptr %tmp170, align 4, !alias.scope !17, !noalias !13
273  br label %bb171
274
275bb171:                                            ; preds = %bb164
276  %tmp172 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 1, i64 0, i64 0, i64 0, i64 1
277  %tmp173 = load float, ptr %tmp172, align 4, !alias.scope !13, !noalias !14
278  %tmp174 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 1, i64 1, i64 0, i64 0
279  store float %tmp173, ptr %tmp174, align 4, !alias.scope !17, !noalias !13
280  %tmp175 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 1, i64 0, i64 1, i64 0, i64 1
281  %tmp176 = load float, ptr %tmp175, align 4, !alias.scope !13, !noalias !14
282  %tmp177 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 1, i64 1, i64 0, i64 1
283  store float %tmp176, ptr %tmp177, align 4, !alias.scope !17, !noalias !13
284  br label %bb178
285
286bb178:                                            ; preds = %bb171
287  br label %bb179
288
289bb179:                                            ; preds = %bb178
290  %tmp180 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 0, i64 0, i64 0, i64 1, i64 0
291  %tmp181 = load float, ptr %tmp180, align 4, !alias.scope !13, !noalias !14
292  %tmp182 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 2, i64 0, i64 0, i64 0
293  store float %tmp181, ptr %tmp182, align 4, !alias.scope !17, !noalias !13
294  %tmp183 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 0, i64 0, i64 1, i64 1, i64 0
295  %tmp184 = load float, ptr %tmp183, align 4, !alias.scope !13, !noalias !14
296  %tmp185 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 2, i64 0, i64 0, i64 1
297  store float %tmp184, ptr %tmp185, align 4, !alias.scope !17, !noalias !13
298  br label %bb186
299
300bb186:                                            ; preds = %bb179
301  %tmp187 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 1, i64 0, i64 0, i64 1, i64 0
302  %tmp188 = load float, ptr %tmp187, align 4, !alias.scope !13, !noalias !14
303  %tmp189 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 2, i64 1, i64 0, i64 0
304  store float %tmp188, ptr %tmp189, align 4, !alias.scope !17, !noalias !13
305  %tmp190 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 1, i64 0, i64 1, i64 1, i64 0
306  %tmp191 = load float, ptr %tmp190, align 4, !alias.scope !13, !noalias !14
307  %tmp192 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 2, i64 1, i64 0, i64 1
308  store float %tmp191, ptr %tmp192, align 4, !alias.scope !17, !noalias !13
309  br label %bb193
310
311bb193:                                            ; preds = %bb186
312  br label %bb194
313
314bb194:                                            ; preds = %bb193
315  %tmp195 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 0, i64 0, i64 0, i64 1, i64 1
316  %tmp196 = load float, ptr %tmp195, align 4, !alias.scope !13, !noalias !14
317  %tmp197 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 3, i64 0, i64 0, i64 0
318  store float %tmp196, ptr %tmp197, align 4, !alias.scope !17, !noalias !13
319  %tmp198 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 0, i64 0, i64 1, i64 1, i64 1
320  %tmp199 = load float, ptr %tmp198, align 4, !alias.scope !13, !noalias !14
321  %tmp200 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 3, i64 0, i64 0, i64 1
322  store float %tmp199, ptr %tmp200, align 4, !alias.scope !17, !noalias !13
323  br label %bb201
324
325bb201:                                            ; preds = %bb194
326  %tmp202 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 1, i64 0, i64 0, i64 1, i64 1
327  %tmp203 = load float, ptr %tmp202, align 4, !alias.scope !13, !noalias !14
328  %tmp204 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 3, i64 1, i64 0, i64 0
329  store float %tmp203, ptr %tmp204, align 4, !alias.scope !17, !noalias !13
330  %tmp205 = getelementptr inbounds [2 x [1 x [2 x [2 x [2 x float]]]]], ptr %tmp67, i64 0, i64 1, i64 0, i64 1, i64 1, i64 1
331  %tmp206 = load float, ptr %tmp205, align 4, !alias.scope !13, !noalias !14
332  %tmp207 = getelementptr inbounds [4 x [2 x [1 x [2 x float]]]], ptr %tmp146, i64 0, i64 3, i64 1, i64 0, i64 1
333  store float %tmp206, ptr %tmp207, align 4, !alias.scope !17, !noalias !13
334  ret void
335}
336
337attributes #0 = { nofree norecurse nounwind uwtable "denormal-fp-math"="preserve-sign" "no-frame-pointer-elim"="false" }
338
339!0 = !{}
340!1 = !{i64 800}
341!2 = !{i64 16}
342!3 = !{i64 1536}
343!4 = !{!5}
344!5 = !{!"buffer: {index:3, offset:0, size:800}", !6}
345!6 = !{!"XLA global AA domain"}
346!7 = !{!8, !9}
347!8 = !{!"buffer: {index:3, offset:800, size:672}", !6}
348!9 = !{!"buffer: {index:3, offset:1472, size:64}", !6}
349!10 = !{i64 672}
350!11 = !{!8}
351!12 = !{!5, !9}
352!13 = !{!9}
353!14 = !{!15, !5, !8}
354!15 = !{!"buffer: {index:2, offset:0, size:64}", !6}
355!16 = !{i64 64}
356!17 = !{!15}
357