1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-distribute -enable-loop-distribute -verify-loop-info -verify-dom-info -S -enable-mem-access-versioning=0 < %s | FileCheck %s
4 ; PredicatedScalarEvolution decides it needs to insert a bounds check
5 ; not based on memory access.
7 define void @f(ptr noalias %a, ptr noalias %b, ptr noalias %c, ptr noalias %d, ptr noalias %e, i64 %N) {
10 ; CHECK-NEXT: br label [[FOR_BODY_LVER_CHECK:%.*]]
11 ; CHECK: for.body.lver.check:
12 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[N:%.*]], -1
13 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i64 [[TMP0]], 4294967295
14 ; CHECK-NEXT: br i1 [[TMP1]], label [[FOR_BODY_PH_LVER_ORIG:%.*]], label [[FOR_BODY_PH_LDIST1:%.*]]
15 ; CHECK: for.body.ph.lver.orig:
16 ; CHECK-NEXT: br label [[FOR_BODY_LVER_ORIG:%.*]]
17 ; CHECK: for.body.lver.orig:
18 ; CHECK-NEXT: [[IND_LVER_ORIG:%.*]] = phi i64 [ 0, [[FOR_BODY_PH_LVER_ORIG]] ], [ [[ADD_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
19 ; CHECK-NEXT: [[IND1_LVER_ORIG:%.*]] = phi i32 [ 0, [[FOR_BODY_PH_LVER_ORIG]] ], [ [[INC1_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
20 ; CHECK-NEXT: [[MUL_LVER_ORIG:%.*]] = mul i32 [[IND1_LVER_ORIG]], 2
21 ; CHECK-NEXT: [[MUL_EXT_LVER_ORIG:%.*]] = zext i32 [[MUL_LVER_ORIG]] to i64
22 ; CHECK-NEXT: [[ARRAYIDXA_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[MUL_EXT_LVER_ORIG]]
23 ; CHECK-NEXT: [[LOADA_LVER_ORIG:%.*]] = load i32, ptr [[ARRAYIDXA_LVER_ORIG]], align 4
24 ; CHECK-NEXT: [[ARRAYIDXB_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr [[B:%.*]], i64 [[MUL_EXT_LVER_ORIG]]
25 ; CHECK-NEXT: [[LOADB_LVER_ORIG:%.*]] = load i32, ptr [[ARRAYIDXB_LVER_ORIG]], align 4
26 ; CHECK-NEXT: [[MULA_LVER_ORIG:%.*]] = mul i32 [[LOADB_LVER_ORIG]], [[LOADA_LVER_ORIG]]
27 ; CHECK-NEXT: [[ADD_LVER_ORIG]] = add nuw nsw i64 [[IND_LVER_ORIG]], 1
28 ; CHECK-NEXT: [[INC1_LVER_ORIG]] = add i32 [[IND1_LVER_ORIG]], 1
29 ; CHECK-NEXT: [[ARRAYIDXA_PLUS_4_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[ADD_LVER_ORIG]]
30 ; CHECK-NEXT: store i32 [[MULA_LVER_ORIG]], ptr [[ARRAYIDXA_PLUS_4_LVER_ORIG]], align 4
31 ; CHECK-NEXT: [[ARRAYIDXD_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr [[D:%.*]], i64 [[MUL_EXT_LVER_ORIG]]
32 ; CHECK-NEXT: [[LOADD_LVER_ORIG:%.*]] = load i32, ptr [[ARRAYIDXD_LVER_ORIG]], align 4
33 ; CHECK-NEXT: [[ARRAYIDXE_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr [[E:%.*]], i64 [[MUL_EXT_LVER_ORIG]]
34 ; CHECK-NEXT: [[LOADE_LVER_ORIG:%.*]] = load i32, ptr [[ARRAYIDXE_LVER_ORIG]], align 4
35 ; CHECK-NEXT: [[MULC_LVER_ORIG:%.*]] = mul i32 [[LOADD_LVER_ORIG]], [[LOADE_LVER_ORIG]]
36 ; CHECK-NEXT: [[ARRAYIDXC_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr [[C:%.*]], i64 [[MUL_EXT_LVER_ORIG]]
37 ; CHECK-NEXT: store i32 [[MULC_LVER_ORIG]], ptr [[ARRAYIDXC_LVER_ORIG]], align 4
38 ; CHECK-NEXT: [[EXITCOND_LVER_ORIG:%.*]] = icmp eq i64 [[ADD_LVER_ORIG]], [[N]]
39 ; CHECK-NEXT: br i1 [[EXITCOND_LVER_ORIG]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY_LVER_ORIG]]
40 ; CHECK: for.body.ph.ldist1:
41 ; CHECK-NEXT: br label [[FOR_BODY_LDIST1:%.*]]
42 ; CHECK: for.body.ldist1:
43 ; CHECK-NEXT: [[IND_LDIST1:%.*]] = phi i64 [ 0, [[FOR_BODY_PH_LDIST1]] ], [ [[ADD_LDIST1:%.*]], [[FOR_BODY_LDIST1]] ]
44 ; CHECK-NEXT: [[IND1_LDIST1:%.*]] = phi i32 [ 0, [[FOR_BODY_PH_LDIST1]] ], [ [[INC1_LDIST1:%.*]], [[FOR_BODY_LDIST1]] ]
45 ; CHECK-NEXT: [[MUL_LDIST1:%.*]] = mul i32 [[IND1_LDIST1]], 2
46 ; CHECK-NEXT: [[MUL_EXT_LDIST1:%.*]] = zext i32 [[MUL_LDIST1]] to i64
47 ; CHECK-NEXT: [[ARRAYIDXA_LDIST1:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[MUL_EXT_LDIST1]]
48 ; CHECK-NEXT: [[LOADA_LDIST1:%.*]] = load i32, ptr [[ARRAYIDXA_LDIST1]], align 4, !alias.scope [[META0:![0-9]+]]
49 ; CHECK-NEXT: [[ARRAYIDXB_LDIST1:%.*]] = getelementptr inbounds i32, ptr [[B]], i64 [[MUL_EXT_LDIST1]]
50 ; CHECK-NEXT: [[LOADB_LDIST1:%.*]] = load i32, ptr [[ARRAYIDXB_LDIST1]], align 4
51 ; CHECK-NEXT: [[MULA_LDIST1:%.*]] = mul i32 [[LOADB_LDIST1]], [[LOADA_LDIST1]]
52 ; CHECK-NEXT: [[ADD_LDIST1]] = add nuw nsw i64 [[IND_LDIST1]], 1
53 ; CHECK-NEXT: [[INC1_LDIST1]] = add i32 [[IND1_LDIST1]], 1
54 ; CHECK-NEXT: [[ARRAYIDXA_PLUS_4_LDIST1:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[ADD_LDIST1]]
55 ; CHECK-NEXT: store i32 [[MULA_LDIST1]], ptr [[ARRAYIDXA_PLUS_4_LDIST1]], align 4, !alias.scope [[META3:![0-9]+]]
56 ; CHECK-NEXT: [[EXITCOND_LDIST1:%.*]] = icmp eq i64 [[ADD_LDIST1]], [[N]]
57 ; CHECK-NEXT: br i1 [[EXITCOND_LDIST1]], label [[FOR_BODY_PH:%.*]], label [[FOR_BODY_LDIST1]]
59 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
61 ; CHECK-NEXT: [[IND:%.*]] = phi i64 [ 0, [[FOR_BODY_PH]] ], [ [[ADD:%.*]], [[FOR_BODY]] ]
62 ; CHECK-NEXT: [[IND1:%.*]] = phi i32 [ 0, [[FOR_BODY_PH]] ], [ [[INC1:%.*]], [[FOR_BODY]] ]
63 ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[IND1]], 2
64 ; CHECK-NEXT: [[MUL_EXT:%.*]] = zext i32 [[MUL]] to i64
65 ; CHECK-NEXT: [[ADD]] = add nuw nsw i64 [[IND]], 1
66 ; CHECK-NEXT: [[INC1]] = add i32 [[IND1]], 1
67 ; CHECK-NEXT: [[ARRAYIDXD:%.*]] = getelementptr inbounds i32, ptr [[D]], i64 [[MUL_EXT]]
68 ; CHECK-NEXT: [[LOADD:%.*]] = load i32, ptr [[ARRAYIDXD]], align 4
69 ; CHECK-NEXT: [[ARRAYIDXE:%.*]] = getelementptr inbounds i32, ptr [[E]], i64 [[MUL_EXT]]
70 ; CHECK-NEXT: [[LOADE:%.*]] = load i32, ptr [[ARRAYIDXE]], align 4
71 ; CHECK-NEXT: [[MULC:%.*]] = mul i32 [[LOADD]], [[LOADE]]
72 ; CHECK-NEXT: [[ARRAYIDXC:%.*]] = getelementptr inbounds i32, ptr [[C]], i64 [[MUL_EXT]]
73 ; CHECK-NEXT: store i32 [[MULC]], ptr [[ARRAYIDXC]], align 4
74 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[ADD]], [[N]]
75 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END_LOOPEXIT2:%.*]], label [[FOR_BODY]]
76 ; CHECK: for.end.loopexit:
77 ; CHECK-NEXT: br label [[FOR_END:%.*]]
78 ; CHECK: for.end.loopexit1:
79 ; CHECK-NEXT: br label [[FOR_END]]
81 ; CHECK-NEXT: ret void
86 for.body: ; preds = %for.body, %entry
87 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
88 %ind1 = phi i32 [ 0, %entry ], [ %inc1, %for.body ]
90 %mul = mul i32 %ind1, 2
91 %mul_ext = zext i32 %mul to i64
94 %arrayidxA = getelementptr inbounds i32, ptr %a, i64 %mul_ext
95 %loadA = load i32, ptr %arrayidxA, align 4
97 %arrayidxB = getelementptr inbounds i32, ptr %b, i64 %mul_ext
98 %loadB = load i32, ptr %arrayidxB, align 4
100 %mulA = mul i32 %loadB, %loadA
102 %add = add nuw nsw i64 %ind, 1
103 %inc1 = add i32 %ind1, 1
105 %arrayidxA_plus_4 = getelementptr inbounds i32, ptr %a, i64 %add
106 store i32 %mulA, ptr %arrayidxA_plus_4, align 4
108 %arrayidxD = getelementptr inbounds i32, ptr %d, i64 %mul_ext
109 %loadD = load i32, ptr %arrayidxD, align 4
111 %arrayidxE = getelementptr inbounds i32, ptr %e, i64 %mul_ext
112 %loadE = load i32, ptr %arrayidxE, align 4
114 %mulC = mul i32 %loadD, %loadE
116 %arrayidxC = getelementptr inbounds i32, ptr %c, i64 %mul_ext
117 store i32 %mulC, ptr %arrayidxC, align 4
119 %exitcond = icmp eq i64 %add, %N
120 br i1 %exitcond, label %for.end, label %for.body
122 for.end: ; preds = %for.body
126 declare void @use64(i64)
127 @global_a = common local_unnamed_addr global [8192 x i32] zeroinitializer, align 16
129 define void @f_with_offset(ptr noalias %b, ptr noalias %c, ptr noalias %d, ptr noalias %e, i64 %N) {
130 ; CHECK-LABEL: @f_with_offset(
132 ; CHECK-NEXT: [[A_INTPTR:%.*]] = ptrtoint ptr @global_a to i64
133 ; CHECK-NEXT: call void @use64(i64 [[A_INTPTR]])
134 ; CHECK-NEXT: [[A:%.*]] = getelementptr i32, ptr @global_a, i32 42
135 ; CHECK-NEXT: br label [[FOR_BODY_LVER_CHECK:%.*]]
136 ; CHECK: for.body.lver.check:
137 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[N:%.*]], -1
138 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i64 [[TMP0]], 4294967295
139 ; CHECK-NEXT: br i1 [[TMP1]], label [[FOR_BODY_PH_LVER_ORIG:%.*]], label [[FOR_BODY_PH_LDIST1:%.*]]
140 ; CHECK: for.body.ph.lver.orig:
141 ; CHECK-NEXT: br label [[FOR_BODY_LVER_ORIG:%.*]]
142 ; CHECK: for.body.lver.orig:
143 ; CHECK-NEXT: [[IND_LVER_ORIG:%.*]] = phi i64 [ 0, [[FOR_BODY_PH_LVER_ORIG]] ], [ [[ADD_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
144 ; CHECK-NEXT: [[IND1_LVER_ORIG:%.*]] = phi i32 [ 0, [[FOR_BODY_PH_LVER_ORIG]] ], [ [[INC1_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
145 ; CHECK-NEXT: [[MUL_LVER_ORIG:%.*]] = mul i32 [[IND1_LVER_ORIG]], 2
146 ; CHECK-NEXT: [[MUL_EXT_LVER_ORIG:%.*]] = zext i32 [[MUL_LVER_ORIG]] to i64
147 ; CHECK-NEXT: [[ARRAYIDXA_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[MUL_EXT_LVER_ORIG]]
148 ; CHECK-NEXT: [[LOADA_LVER_ORIG:%.*]] = load i32, ptr [[ARRAYIDXA_LVER_ORIG]], align 4
149 ; CHECK-NEXT: [[ARRAYIDXB_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr [[B:%.*]], i64 [[MUL_EXT_LVER_ORIG]]
150 ; CHECK-NEXT: [[LOADB_LVER_ORIG:%.*]] = load i32, ptr [[ARRAYIDXB_LVER_ORIG]], align 4
151 ; CHECK-NEXT: [[MULA_LVER_ORIG:%.*]] = mul i32 [[LOADB_LVER_ORIG]], [[LOADA_LVER_ORIG]]
152 ; CHECK-NEXT: [[ADD_LVER_ORIG]] = add nuw nsw i64 [[IND_LVER_ORIG]], 1
153 ; CHECK-NEXT: [[INC1_LVER_ORIG]] = add i32 [[IND1_LVER_ORIG]], 1
154 ; CHECK-NEXT: [[ARRAYIDXA_PLUS_4_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[ADD_LVER_ORIG]]
155 ; CHECK-NEXT: store i32 [[MULA_LVER_ORIG]], ptr [[ARRAYIDXA_PLUS_4_LVER_ORIG]], align 4
156 ; CHECK-NEXT: [[ARRAYIDXD_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr [[D:%.*]], i64 [[MUL_EXT_LVER_ORIG]]
157 ; CHECK-NEXT: [[LOADD_LVER_ORIG:%.*]] = load i32, ptr [[ARRAYIDXD_LVER_ORIG]], align 4
158 ; CHECK-NEXT: [[ARRAYIDXE_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr [[E:%.*]], i64 [[MUL_EXT_LVER_ORIG]]
159 ; CHECK-NEXT: [[LOADE_LVER_ORIG:%.*]] = load i32, ptr [[ARRAYIDXE_LVER_ORIG]], align 4
160 ; CHECK-NEXT: [[MULC_LVER_ORIG:%.*]] = mul i32 [[LOADD_LVER_ORIG]], [[LOADE_LVER_ORIG]]
161 ; CHECK-NEXT: [[ARRAYIDXC_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr [[C:%.*]], i64 [[MUL_EXT_LVER_ORIG]]
162 ; CHECK-NEXT: store i32 [[MULC_LVER_ORIG]], ptr [[ARRAYIDXC_LVER_ORIG]], align 4
163 ; CHECK-NEXT: [[EXITCOND_LVER_ORIG:%.*]] = icmp eq i64 [[ADD_LVER_ORIG]], [[N]]
164 ; CHECK-NEXT: br i1 [[EXITCOND_LVER_ORIG]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY_LVER_ORIG]]
165 ; CHECK: for.body.ph.ldist1:
166 ; CHECK-NEXT: br label [[FOR_BODY_LDIST1:%.*]]
167 ; CHECK: for.body.ldist1:
168 ; CHECK-NEXT: [[IND_LDIST1:%.*]] = phi i64 [ 0, [[FOR_BODY_PH_LDIST1]] ], [ [[ADD_LDIST1:%.*]], [[FOR_BODY_LDIST1]] ]
169 ; CHECK-NEXT: [[IND1_LDIST1:%.*]] = phi i32 [ 0, [[FOR_BODY_PH_LDIST1]] ], [ [[INC1_LDIST1:%.*]], [[FOR_BODY_LDIST1]] ]
170 ; CHECK-NEXT: [[MUL_LDIST1:%.*]] = mul i32 [[IND1_LDIST1]], 2
171 ; CHECK-NEXT: [[MUL_EXT_LDIST1:%.*]] = zext i32 [[MUL_LDIST1]] to i64
172 ; CHECK-NEXT: [[ARRAYIDXA_LDIST1:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[MUL_EXT_LDIST1]]
173 ; CHECK-NEXT: [[LOADA_LDIST1:%.*]] = load i32, ptr [[ARRAYIDXA_LDIST1]], align 4, !alias.scope [[META5:![0-9]+]]
174 ; CHECK-NEXT: [[ARRAYIDXB_LDIST1:%.*]] = getelementptr inbounds i32, ptr [[B]], i64 [[MUL_EXT_LDIST1]]
175 ; CHECK-NEXT: [[LOADB_LDIST1:%.*]] = load i32, ptr [[ARRAYIDXB_LDIST1]], align 4
176 ; CHECK-NEXT: [[MULA_LDIST1:%.*]] = mul i32 [[LOADB_LDIST1]], [[LOADA_LDIST1]]
177 ; CHECK-NEXT: [[ADD_LDIST1]] = add nuw nsw i64 [[IND_LDIST1]], 1
178 ; CHECK-NEXT: [[INC1_LDIST1]] = add i32 [[IND1_LDIST1]], 1
179 ; CHECK-NEXT: [[ARRAYIDXA_PLUS_4_LDIST1:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[ADD_LDIST1]]
180 ; CHECK-NEXT: store i32 [[MULA_LDIST1]], ptr [[ARRAYIDXA_PLUS_4_LDIST1]], align 4, !alias.scope [[META8:![0-9]+]]
181 ; CHECK-NEXT: [[EXITCOND_LDIST1:%.*]] = icmp eq i64 [[ADD_LDIST1]], [[N]]
182 ; CHECK-NEXT: br i1 [[EXITCOND_LDIST1]], label [[FOR_BODY_PH:%.*]], label [[FOR_BODY_LDIST1]]
183 ; CHECK: for.body.ph:
184 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
186 ; CHECK-NEXT: [[IND:%.*]] = phi i64 [ 0, [[FOR_BODY_PH]] ], [ [[ADD:%.*]], [[FOR_BODY]] ]
187 ; CHECK-NEXT: [[IND1:%.*]] = phi i32 [ 0, [[FOR_BODY_PH]] ], [ [[INC1:%.*]], [[FOR_BODY]] ]
188 ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[IND1]], 2
189 ; CHECK-NEXT: [[MUL_EXT:%.*]] = zext i32 [[MUL]] to i64
190 ; CHECK-NEXT: [[ADD]] = add nuw nsw i64 [[IND]], 1
191 ; CHECK-NEXT: [[INC1]] = add i32 [[IND1]], 1
192 ; CHECK-NEXT: [[ARRAYIDXD:%.*]] = getelementptr inbounds i32, ptr [[D]], i64 [[MUL_EXT]]
193 ; CHECK-NEXT: [[LOADD:%.*]] = load i32, ptr [[ARRAYIDXD]], align 4
194 ; CHECK-NEXT: [[ARRAYIDXE:%.*]] = getelementptr inbounds i32, ptr [[E]], i64 [[MUL_EXT]]
195 ; CHECK-NEXT: [[LOADE:%.*]] = load i32, ptr [[ARRAYIDXE]], align 4
196 ; CHECK-NEXT: [[MULC:%.*]] = mul i32 [[LOADD]], [[LOADE]]
197 ; CHECK-NEXT: [[ARRAYIDXC:%.*]] = getelementptr inbounds i32, ptr [[C]], i64 [[MUL_EXT]]
198 ; CHECK-NEXT: store i32 [[MULC]], ptr [[ARRAYIDXC]], align 4
199 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[ADD]], [[N]]
200 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END_LOOPEXIT2:%.*]], label [[FOR_BODY]]
201 ; CHECK: for.end.loopexit:
202 ; CHECK-NEXT: br label [[FOR_END:%.*]]
203 ; CHECK: for.end.loopexit1:
204 ; CHECK-NEXT: br label [[FOR_END]]
206 ; CHECK-NEXT: ret void
209 %a_intptr = ptrtoint ptr @global_a to i64
210 call void @use64(i64 %a_intptr)
211 %a = getelementptr i32, ptr @global_a, i32 42
214 for.body: ; preds = %for.body, %entry
215 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
216 %ind1 = phi i32 [ 0, %entry ], [ %inc1, %for.body ]
218 %mul = mul i32 %ind1, 2
219 %mul_ext = zext i32 %mul to i64
222 %arrayidxA = getelementptr inbounds i32, ptr %a, i64 %mul_ext
223 %loadA = load i32, ptr %arrayidxA, align 4
225 %arrayidxB = getelementptr inbounds i32, ptr %b, i64 %mul_ext
226 %loadB = load i32, ptr %arrayidxB, align 4
228 %mulA = mul i32 %loadB, %loadA
230 %add = add nuw nsw i64 %ind, 1
231 %inc1 = add i32 %ind1, 1
233 %arrayidxA_plus_4 = getelementptr inbounds i32, ptr %a, i64 %add
234 store i32 %mulA, ptr %arrayidxA_plus_4, align 4
236 %arrayidxD = getelementptr inbounds i32, ptr %d, i64 %mul_ext
237 %loadD = load i32, ptr %arrayidxD, align 4
239 %arrayidxE = getelementptr inbounds i32, ptr %e, i64 %mul_ext
240 %loadE = load i32, ptr %arrayidxE, align 4
242 %mulC = mul i32 %loadD, %loadE
244 %arrayidxC = getelementptr inbounds i32, ptr %c, i64 %mul_ext
245 store i32 %mulC, ptr %arrayidxC, align 4
247 %exitcond = icmp eq i64 %add, %N
248 br i1 %exitcond, label %for.end, label %for.body
250 for.end: ; preds = %for.body
254 ; Can't add control dependency with convergent in loop body.
255 define void @f_with_convergent(ptr noalias %a, ptr noalias %b, ptr noalias %c, ptr noalias %d, ptr noalias %e, i64 %N) #1 {
256 ; CHECK-LABEL: @f_with_convergent(
258 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
260 ; CHECK-NEXT: [[IND:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[ADD:%.*]], [[FOR_BODY]] ]
261 ; CHECK-NEXT: [[IND1:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC1:%.*]], [[FOR_BODY]] ]
262 ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[IND1]], 2
263 ; CHECK-NEXT: [[MUL_EXT:%.*]] = zext i32 [[MUL]] to i64
264 ; CHECK-NEXT: [[ARRAYIDXA:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[MUL_EXT]]
265 ; CHECK-NEXT: [[LOADA:%.*]] = load i32, ptr [[ARRAYIDXA]], align 4
266 ; CHECK-NEXT: [[ARRAYIDXB:%.*]] = getelementptr inbounds i32, ptr [[B:%.*]], i64 [[MUL_EXT]]
267 ; CHECK-NEXT: [[LOADB:%.*]] = load i32, ptr [[ARRAYIDXB]], align 4
268 ; CHECK-NEXT: [[MULA:%.*]] = mul i32 [[LOADB]], [[LOADA]]
269 ; CHECK-NEXT: [[ADD]] = add nuw nsw i64 [[IND]], 1
270 ; CHECK-NEXT: [[INC1]] = add i32 [[IND1]], 1
271 ; CHECK-NEXT: [[ARRAYIDXA_PLUS_4:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[ADD]]
272 ; CHECK-NEXT: store i32 [[MULA]], ptr [[ARRAYIDXA_PLUS_4]], align 4
273 ; CHECK-NEXT: [[ARRAYIDXD:%.*]] = getelementptr inbounds i32, ptr [[D:%.*]], i64 [[MUL_EXT]]
274 ; CHECK-NEXT: [[LOADD:%.*]] = load i32, ptr [[ARRAYIDXD]], align 4
275 ; CHECK-NEXT: [[ARRAYIDXE:%.*]] = getelementptr inbounds i32, ptr [[E:%.*]], i64 [[MUL_EXT]]
276 ; CHECK-NEXT: [[LOADE:%.*]] = load i32, ptr [[ARRAYIDXE]], align 4
277 ; CHECK-NEXT: [[CONVERGENTD:%.*]] = call i32 @llvm.convergent(i32 [[LOADD]])
278 ; CHECK-NEXT: [[MULC:%.*]] = mul i32 [[CONVERGENTD]], [[LOADE]]
279 ; CHECK-NEXT: [[ARRAYIDXC:%.*]] = getelementptr inbounds i32, ptr [[C:%.*]], i64 [[MUL_EXT]]
280 ; CHECK-NEXT: store i32 [[MULC]], ptr [[ARRAYIDXC]], align 4
281 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[ADD]], [[N:%.*]]
282 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
284 ; CHECK-NEXT: ret void
289 for.body: ; preds = %for.body, %entry
290 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
291 %ind1 = phi i32 [ 0, %entry ], [ %inc1, %for.body ]
293 %mul = mul i32 %ind1, 2
294 %mul_ext = zext i32 %mul to i64
297 %arrayidxA = getelementptr inbounds i32, ptr %a, i64 %mul_ext
298 %loadA = load i32, ptr %arrayidxA, align 4
300 %arrayidxB = getelementptr inbounds i32, ptr %b, i64 %mul_ext
301 %loadB = load i32, ptr %arrayidxB, align 4
303 %mulA = mul i32 %loadB, %loadA
305 %add = add nuw nsw i64 %ind, 1
306 %inc1 = add i32 %ind1, 1
308 %arrayidxA_plus_4 = getelementptr inbounds i32, ptr %a, i64 %add
309 store i32 %mulA, ptr %arrayidxA_plus_4, align 4
311 %arrayidxD = getelementptr inbounds i32, ptr %d, i64 %mul_ext
312 %loadD = load i32, ptr %arrayidxD, align 4
314 %arrayidxE = getelementptr inbounds i32, ptr %e, i64 %mul_ext
315 %loadE = load i32, ptr %arrayidxE, align 4
317 %convergentD = call i32 @llvm.convergent(i32 %loadD)
318 %mulC = mul i32 %convergentD, %loadE
320 %arrayidxC = getelementptr inbounds i32, ptr %c, i64 %mul_ext
321 store i32 %mulC, ptr %arrayidxC, align 4
323 %exitcond = icmp eq i64 %add, %N
324 br i1 %exitcond, label %for.end, label %for.body
326 for.end: ; preds = %for.body
330 declare i32 @llvm.convergent(i32) #0
332 attributes #0 = { nounwind readnone convergent }
333 attributes #1 = { nounwind convergent }