1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -loop-idiom < %s -S | FileCheck %s
4 %struct.S = type { i32, i32, i8 }
6 ; unsigned copy_noalias(S* __restrict a, S *b, int n) {
7 ; for (int i = 0; i < n; i++) {
10 ; return sizeof(a[0]);
13 ; Function Attrs: nofree nounwind uwtable mustprogress
14 define dso_local i32 @copy_noalias(%struct.S* noalias nocapture %a, %struct.S* nocapture readonly %b, i32 %n) local_unnamed_addr #0 {
15 ; CHECK-LABEL: @copy_noalias(
17 ; CHECK-NEXT: [[A1:%.*]] = bitcast %struct.S* [[A:%.*]] to i8*
18 ; CHECK-NEXT: [[B2:%.*]] = bitcast %struct.S* [[B:%.*]] to i8*
19 ; CHECK-NEXT: [[CMP7:%.*]] = icmp sgt i32 [[N:%.*]], 0
20 ; CHECK-NEXT: br i1 [[CMP7]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
21 ; CHECK: for.body.preheader:
22 ; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
23 ; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i64 [[TMP0]], 12
24 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[A1]], i8* align 4 [[B2]], i64 [[TMP1]], i1 false)
25 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
26 ; CHECK: for.cond.cleanup.loopexit:
27 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
28 ; CHECK: for.cond.cleanup:
29 ; CHECK-NEXT: ret i32 12
31 ; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
32 ; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[I_08]] to i64
33 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], %struct.S* [[B]], i64 [[IDXPROM]]
34 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [[STRUCT_S]], %struct.S* [[A]], i64 [[IDXPROM]]
35 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast %struct.S* [[ARRAYIDX2]] to i8*
36 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast %struct.S* [[ARRAYIDX]] to i8*
37 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
38 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[N]]
39 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]]
42 %cmp7 = icmp sgt i32 %n, 0
43 br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup
45 for.body.preheader: ; preds = %entry
48 for.cond.cleanup.loopexit: ; preds = %for.body
49 br label %for.cond.cleanup
51 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
54 for.body: ; preds = %for.body.preheader, %for.body
55 %i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
56 %idxprom = zext i32 %i.08 to i64
57 %arrayidx = getelementptr inbounds %struct.S, %struct.S* %b, i64 %idxprom
58 %arrayidx2 = getelementptr inbounds %struct.S, %struct.S* %a, i64 %idxprom
59 %0 = bitcast %struct.S* %arrayidx2 to i8*
60 %1 = bitcast %struct.S* %arrayidx to i8*
61 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 dereferenceable(12) %0, i8* nonnull align 4 dereferenceable(12) %1, i64 12, i1 false)
62 %inc = add nuw nsw i32 %i.08, 1
63 %cmp = icmp slt i32 %inc, %n
64 br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit
67 ; unsigned copy_may_alias(S *a, S *b, int n) {
68 ; for (int i = 0; i < n; i++) {
71 ; return sizeof(a[0]);
74 ; Function Attrs: nofree nounwind uwtable mustprogress
75 define dso_local i32 @copy_may_alias(%struct.S* nocapture %a, %struct.S* nocapture readonly %b, i32 %n) local_unnamed_addr #0 {
76 ; CHECK-LABEL: @copy_may_alias(
78 ; CHECK-NEXT: [[CMP7:%.*]] = icmp sgt i32 [[N:%.*]], 0
79 ; CHECK-NEXT: br i1 [[CMP7]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
80 ; CHECK: for.body.preheader:
81 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
82 ; CHECK: for.cond.cleanup.loopexit:
83 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
84 ; CHECK: for.cond.cleanup:
85 ; CHECK-NEXT: ret i32 12
87 ; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
88 ; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[I_08]] to i64
89 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], %struct.S* [[B:%.*]], i64 [[IDXPROM]]
90 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [[STRUCT_S]], %struct.S* [[A:%.*]], i64 [[IDXPROM]]
91 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast %struct.S* [[ARRAYIDX2]] to i8*
92 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast %struct.S* [[ARRAYIDX]] to i8*
93 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 dereferenceable(12) [[TMP0]], i8* nonnull align 4 dereferenceable(12) [[TMP1]], i64 12, i1 false)
94 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
95 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[N]]
96 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]]
99 %cmp7 = icmp sgt i32 %n, 0
100 br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup
102 for.body.preheader: ; preds = %entry
105 for.cond.cleanup.loopexit: ; preds = %for.body
106 br label %for.cond.cleanup
108 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
111 for.body: ; preds = %for.body.preheader, %for.body
112 %i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
113 %idxprom = zext i32 %i.08 to i64
114 %arrayidx = getelementptr inbounds %struct.S, %struct.S* %b, i64 %idxprom
115 %arrayidx2 = getelementptr inbounds %struct.S, %struct.S* %a, i64 %idxprom
116 %0 = bitcast %struct.S* %arrayidx2 to i8*
117 %1 = bitcast %struct.S* %arrayidx to i8*
118 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 dereferenceable(12) %0, i8* nonnull align 4 dereferenceable(12) %1, i64 12, i1 false)
119 %inc = add nuw nsw i32 %i.08, 1
120 %cmp = icmp slt i32 %inc, %n
121 br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit
124 %struct.R = type <{ i8, i32, i8 }>
126 ; void copy_noalias_read(S* __restrict x, S* __restrict y, int n, int &s) {
127 ; for (int i = 0; i < n; i++) {
133 ; Function Attrs: nofree nounwind uwtable mustprogress
134 define dso_local void @copy_noalias_read(%struct.R* noalias nocapture %x, %struct.R* noalias nocapture readonly %y, i32 %n, i32* nocapture nonnull align 4 dereferenceable(4) %s) local_unnamed_addr #0 {
135 ; CHECK-LABEL: @copy_noalias_read(
137 ; CHECK-NEXT: [[X1:%.*]] = bitcast %struct.R* [[X:%.*]] to i8*
138 ; CHECK-NEXT: [[Y2:%.*]] = bitcast %struct.R* [[Y:%.*]] to i8*
139 ; CHECK-NEXT: [[CMP11:%.*]] = icmp sgt i32 [[N:%.*]], 0
140 ; CHECK-NEXT: br i1 [[CMP11]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_COND_CLEANUP:%.*]]
141 ; CHECK: for.body.lr.ph:
142 ; CHECK-NEXT: [[S_PROMOTED:%.*]] = load i32, i32* [[S:%.*]], align 4
143 ; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
144 ; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i64 [[TMP0]], 6
145 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 [[X1]], i8* align 1 [[Y2]], i64 [[TMP1]], i1 false)
146 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
147 ; CHECK: for.cond.for.cond.cleanup_crit_edge:
148 ; CHECK-NEXT: [[ADD_LCSSA:%.*]] = phi i32 [ [[ADD:%.*]], [[FOR_BODY]] ]
149 ; CHECK-NEXT: store i32 [[ADD_LCSSA]], i32* [[S]], align 4
150 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
151 ; CHECK: for.cond.cleanup:
152 ; CHECK-NEXT: ret void
154 ; CHECK-NEXT: [[ADD13:%.*]] = phi i32 [ [[S_PROMOTED]], [[FOR_BODY_LR_PH]] ], [ [[ADD]], [[FOR_BODY]] ]
155 ; CHECK-NEXT: [[I_012:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
156 ; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[I_012]] to i64
157 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds [[STRUCT_R:%.*]], %struct.R* [[X]], i64 [[IDXPROM]], i32 0
158 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [[STRUCT_R]], %struct.R* [[Y]], i64 [[IDXPROM]], i32 0
159 ; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds [[STRUCT_R]], %struct.R* [[Y]], i64 [[IDXPROM]], i32 1
160 ; CHECK-NEXT: [[TMP4:%.*]] = load i32, i32* [[B]], align 1
161 ; CHECK-NEXT: [[ADD]] = add nsw i32 [[ADD13]], [[TMP4]]
162 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_012]], 1
163 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[N]]
164 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_FOR_COND_CLEANUP_CRIT_EDGE:%.*]]
167 %cmp11 = icmp sgt i32 %n, 0
168 br i1 %cmp11, label %for.body.lr.ph, label %for.cond.cleanup
170 for.body.lr.ph: ; preds = %entry
171 %s.promoted = load i32, i32* %s, align 4
174 for.cond.for.cond.cleanup_crit_edge: ; preds = %for.body
175 %add.lcssa = phi i32 [ %add, %for.body ]
176 store i32 %add.lcssa, i32* %s, align 4
177 br label %for.cond.cleanup
179 for.cond.cleanup: ; preds = %for.cond.for.cond.cleanup_crit_edge, %entry
182 for.body: ; preds = %for.body.lr.ph, %for.body
183 %add13 = phi i32 [ %s.promoted, %for.body.lr.ph ], [ %add, %for.body ]
184 %i.012 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
185 %idxprom = zext i32 %i.012 to i64
186 %0 = getelementptr inbounds %struct.R, %struct.R* %x, i64 %idxprom, i32 0
187 %1 = getelementptr inbounds %struct.R, %struct.R* %y, i64 %idxprom, i32 0
188 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 dereferenceable(6) %0, i8* nonnull align 1 dereferenceable(6) %1, i64 6, i1 false)
189 %b = getelementptr inbounds %struct.R, %struct.R* %y, i64 %idxprom, i32 1
190 %2 = load i32, i32* %b, align 1
191 %add = add nsw i32 %add13, %2
192 %inc = add nuw nsw i32 %i.012, 1
193 %cmp = icmp slt i32 %inc, %n
194 br i1 %cmp, label %for.body, label %for.cond.for.cond.cleanup_crit_edge
197 ; unsigned copy_noalias_negative_stride(S* __restrict__ a, S* b, int n) {
198 ; for (int i = n; i >= 0; i--) {
201 ; return sizeof(a[0]);
204 ; Function Attrs: nofree nosync nounwind uwtable mustprogress
205 define dso_local i32 @copy_noalias_negative_stride(%struct.S* noalias nocapture %0, %struct.S* nocapture readonly %1, i32 %2) local_unnamed_addr #0 {
206 ; CHECK-LABEL: @copy_noalias_negative_stride(
207 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast %struct.S* [[TMP0:%.*]] to i8*
208 ; CHECK-NEXT: [[TMP5:%.*]] = bitcast %struct.S* [[TMP1:%.*]] to i8*
209 ; CHECK-NEXT: [[TMP6:%.*]] = icmp sgt i32 [[TMP2:%.*]], -1
210 ; CHECK-NEXT: br i1 [[TMP6]], label [[TMP7:%.*]], label [[TMP12:%.*]]
212 ; CHECK-NEXT: [[TMP8:%.*]] = zext i32 [[TMP2]] to i64
213 ; CHECK-NEXT: [[TMP9:%.*]] = mul nuw nsw i64 [[TMP8]], 12
214 ; CHECK-NEXT: [[TMP10:%.*]] = add nuw nsw i64 [[TMP9]], 12
215 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[TMP4]], i8* align 4 [[TMP5]], i64 [[TMP10]], i1 false)
216 ; CHECK-NEXT: br label [[TMP13:%.*]]
218 ; CHECK-NEXT: br label [[TMP12]]
220 ; CHECK-NEXT: ret i32 12
222 ; CHECK-NEXT: [[TMP14:%.*]] = phi i32 [ [[TMP20:%.*]], [[TMP13]] ], [ [[TMP2]], [[TMP7]] ]
223 ; CHECK-NEXT: [[TMP15:%.*]] = zext i32 [[TMP14]] to i64
224 ; CHECK-NEXT: [[TMP16:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], %struct.S* [[TMP1]], i64 [[TMP15]]
225 ; CHECK-NEXT: [[TMP17:%.*]] = getelementptr inbounds [[STRUCT_S]], %struct.S* [[TMP0]], i64 [[TMP15]]
226 ; CHECK-NEXT: [[TMP18:%.*]] = bitcast %struct.S* [[TMP17]] to i8*
227 ; CHECK-NEXT: [[TMP19:%.*]] = bitcast %struct.S* [[TMP16]] to i8*
228 ; CHECK-NEXT: [[TMP20]] = add nsw i32 [[TMP14]], -1
229 ; CHECK-NEXT: [[TMP21:%.*]] = icmp sgt i32 [[TMP14]], 0
230 ; CHECK-NEXT: br i1 [[TMP21]], label [[TMP13]], label [[TMP11:%.*]]
232 %4 = icmp sgt i32 %2, -1
233 br i1 %4, label %5, label %7
245 %9 = phi i32 [ %15, %8 ], [ %2, %5 ]
246 %10 = zext i32 %9 to i64
247 %11 = getelementptr inbounds %struct.S, %struct.S* %1, i64 %10
248 %12 = getelementptr inbounds %struct.S, %struct.S* %0, i64 %10
249 %13 = bitcast %struct.S* %12 to i8*
250 %14 = bitcast %struct.S* %11 to i8*
251 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 4 dereferenceable(12) %13, i8* noundef nonnull align 4 dereferenceable(12) %14, i64 12, i1 false)
252 %15 = add nsw i32 %9, -1
253 %16 = icmp sgt i32 %9, 0
254 br i1 %16, label %8, label %6
257 ; unsigned copy_noalias_opposite_stride(S* __restrict__ a, S* b, int n) {
258 ; for (int i = 0, j = n; i < n && j >= 0; i++, j--) {
261 ; return sizeof(a[0]);
264 ; Function Attrs: nofree nosync nounwind uwtable mustprogress
265 define dso_local i32 @copy_noalias_opposite_stride(%struct.S* noalias nocapture %0, %struct.S* nocapture readonly %1, i32 %2) local_unnamed_addr #0 {
266 ; CHECK-LABEL: @copy_noalias_opposite_stride(
267 ; CHECK-NEXT: [[TMP4:%.*]] = icmp sgt i32 [[TMP2:%.*]], 0
268 ; CHECK-NEXT: br i1 [[TMP4]], label [[TMP5:%.*]], label [[TMP7:%.*]]
270 ; CHECK-NEXT: br label [[TMP8:%.*]]
272 ; CHECK-NEXT: br label [[TMP7]]
274 ; CHECK-NEXT: ret i32 12
276 ; CHECK-NEXT: [[TMP9:%.*]] = phi i32 [ [[TMP18:%.*]], [[TMP8]] ], [ [[TMP2]], [[TMP5]] ]
277 ; CHECK-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP17:%.*]], [[TMP8]] ], [ 0, [[TMP5]] ]
278 ; CHECK-NEXT: [[TMP11:%.*]] = zext i32 [[TMP9]] to i64
279 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], %struct.S* [[TMP1:%.*]], i64 [[TMP11]]
280 ; CHECK-NEXT: [[TMP13:%.*]] = zext i32 [[TMP10]] to i64
281 ; CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds [[STRUCT_S]], %struct.S* [[TMP0:%.*]], i64 [[TMP13]]
282 ; CHECK-NEXT: [[TMP15:%.*]] = bitcast %struct.S* [[TMP14]] to i8*
283 ; CHECK-NEXT: [[TMP16:%.*]] = bitcast %struct.S* [[TMP12]] to i8*
284 ; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 4 dereferenceable(12) [[TMP15]], i8* noundef nonnull align 4 dereferenceable(12) [[TMP16]], i64 12, i1 false)
285 ; CHECK-NEXT: [[TMP17]] = add nuw nsw i32 [[TMP10]], 1
286 ; CHECK-NEXT: [[TMP18]] = add nsw i32 [[TMP9]], -1
287 ; CHECK-NEXT: [[TMP19:%.*]] = icmp slt i32 [[TMP17]], [[TMP2]]
288 ; CHECK-NEXT: [[TMP20:%.*]] = icmp sgt i32 [[TMP9]], 0
289 ; CHECK-NEXT: [[TMP21:%.*]] = and i1 [[TMP19]], [[TMP20]]
290 ; CHECK-NEXT: br i1 [[TMP21]], label [[TMP8]], label [[TMP6:%.*]]
292 %4 = icmp sgt i32 %2, 0
293 br i1 %4, label %5, label %7
305 %9 = phi i32 [ %18, %8 ], [ %2, %5 ]
306 %10 = phi i32 [ %17, %8 ], [ 0, %5 ]
307 %11 = zext i32 %9 to i64
308 %12 = getelementptr inbounds %struct.S, %struct.S* %1, i64 %11
309 %13 = zext i32 %10 to i64
310 %14 = getelementptr inbounds %struct.S, %struct.S* %0, i64 %13
311 %15 = bitcast %struct.S* %14 to i8*
312 %16 = bitcast %struct.S* %12 to i8*
313 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 4 dereferenceable(12) %15, i8* noundef nonnull align 4 dereferenceable(12) %16, i64 12, i1 false)
314 %17 = add nuw nsw i32 %10, 1
315 %18 = add nsw i32 %9, -1
316 %19 = icmp slt i32 %17, %2
317 %20 = icmp sgt i32 %9, 0
318 %21 = and i1 %19, %20
319 br i1 %21, label %8, label %6
322 %struct.SPacked = type <{ i32, i32, i8 }>
324 ; Function Attrs: nofree nounwind uwtable mustprogress
325 define dso_local i32 @copy_noalias_packed(%struct.SPacked* noalias nocapture %a, %struct.SPacked* nocapture readonly %b, i32 %n) local_unnamed_addr #0 {
326 ; CHECK-LABEL: @copy_noalias_packed(
328 ; CHECK-NEXT: [[A1:%.*]] = bitcast %struct.SPacked* [[A:%.*]] to i8*
329 ; CHECK-NEXT: [[B2:%.*]] = bitcast %struct.SPacked* [[B:%.*]] to i8*
330 ; CHECK-NEXT: [[CMP7:%.*]] = icmp sgt i32 [[N:%.*]], 0
331 ; CHECK-NEXT: br i1 [[CMP7]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
332 ; CHECK: for.body.preheader:
333 ; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
334 ; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i64 [[TMP0]], 9
335 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 [[A1]], i8* align 1 [[B2]], i64 [[TMP1]], i1 false)
336 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
337 ; CHECK: for.cond.cleanup.loopexit:
338 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
339 ; CHECK: for.cond.cleanup:
340 ; CHECK-NEXT: ret i32 9
342 ; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
343 ; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[I_08]] to i64
344 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_SPACKED:%.*]], %struct.SPacked* [[B]], i64 [[IDXPROM]]
345 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [[STRUCT_SPACKED]], %struct.SPacked* [[A]], i64 [[IDXPROM]]
346 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast %struct.SPacked* [[ARRAYIDX2]] to i8*
347 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast %struct.SPacked* [[ARRAYIDX]] to i8*
348 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
349 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[N]]
350 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]]
353 %cmp7 = icmp sgt i32 %n, 0
354 br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup
356 for.body.preheader: ; preds = %entry
359 for.cond.cleanup.loopexit: ; preds = %for.body
360 br label %for.cond.cleanup
362 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
365 for.body: ; preds = %for.body.preheader, %for.body
366 %i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
367 %idxprom = zext i32 %i.08 to i64
368 %arrayidx = getelementptr inbounds %struct.SPacked, %struct.SPacked* %b, i64 %idxprom
369 %arrayidx2 = getelementptr inbounds %struct.SPacked, %struct.SPacked* %a, i64 %idxprom
370 %0 = bitcast %struct.SPacked* %arrayidx2 to i8*
371 %1 = bitcast %struct.SPacked* %arrayidx to i8*
372 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 dereferenceable(9) %0, i8* nonnull align 1 dereferenceable(9) %1, i64 9, i1 false)
373 %inc = add nuw nsw i32 %i.08, 1
374 %cmp = icmp slt i32 %inc, %n
375 br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit
378 %struct.SAligned = type { i32, i32, i8, [7 x i8] }
380 define dso_local i32 @copy_noalias_aligned(%struct.SAligned* noalias nocapture %a, %struct.SAligned* nocapture readonly %b, i32 %n) local_unnamed_addr #0 {
381 ; CHECK-LABEL: @copy_noalias_aligned(
383 ; CHECK-NEXT: [[A1:%.*]] = bitcast %struct.SAligned* [[A:%.*]] to i8*
384 ; CHECK-NEXT: [[B2:%.*]] = bitcast %struct.SAligned* [[B:%.*]] to i8*
385 ; CHECK-NEXT: [[CMP7:%.*]] = icmp sgt i32 [[N:%.*]], 0
386 ; CHECK-NEXT: br i1 [[CMP7]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
387 ; CHECK: for.body.preheader:
388 ; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
389 ; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 4
390 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 [[A1]], i8* align 16 [[B2]], i64 [[TMP1]], i1 false)
391 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
392 ; CHECK: for.cond.cleanup.loopexit:
393 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
394 ; CHECK: for.cond.cleanup:
395 ; CHECK-NEXT: ret i32 16
397 ; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
398 ; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[I_08]] to i64
399 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_SALIGNED:%.*]], %struct.SAligned* [[B]], i64 [[IDXPROM]]
400 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [[STRUCT_SALIGNED]], %struct.SAligned* [[A]], i64 [[IDXPROM]]
401 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast %struct.SAligned* [[ARRAYIDX2]] to i8*
402 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast %struct.SAligned* [[ARRAYIDX]] to i8*
403 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
404 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[N]]
405 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]]
408 %cmp7 = icmp sgt i32 %n, 0
409 br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup
411 for.body.preheader: ; preds = %entry
414 for.cond.cleanup.loopexit: ; preds = %for.body
415 br label %for.cond.cleanup
417 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
420 for.body: ; preds = %for.body.preheader, %for.body
421 %i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
422 %idxprom = zext i32 %i.08 to i64
423 %arrayidx = getelementptr inbounds %struct.SAligned, %struct.SAligned* %b, i64 %idxprom
424 %arrayidx2 = getelementptr inbounds %struct.SAligned, %struct.SAligned* %a, i64 %idxprom
425 %0 = bitcast %struct.SAligned* %arrayidx2 to i8*
426 %1 = bitcast %struct.SAligned* %arrayidx to i8*
427 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 16 dereferenceable(16) %0, i8* nonnull align 16 dereferenceable(16) %1, i64 16, i1 false)
428 %inc = add nuw nsw i32 %i.08, 1
429 %cmp = icmp slt i32 %inc, %n
430 br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit
433 ; Function Attrs: argmemonly nofree nosync nounwind willreturn
434 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1