1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basic-aa -slp-vectorizer -slp-threshold=-100 -instcombine -dce -S -mtriple=i386-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
4 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"
6 ; Make sure we order the operands of commutative operations so that we get
7 ; bigger vectorizable trees.
9 define void @shuffle_operands1(double * noalias %from, double * noalias %to, double %v1, double %v2) {
10 ; CHECK-LABEL: @shuffle_operands1(
11 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast double* [[FROM:%.*]] to <2 x double>*
12 ; CHECK-NEXT: [[TMP2:%.*]] = load <2 x double>, <2 x double>* [[TMP1]], align 4
13 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x double> poison, double [[V1:%.*]], i32 0
14 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x double> [[TMP3]], double [[V2:%.*]], i32 1
15 ; CHECK-NEXT: [[TMP5:%.*]] = fadd <2 x double> [[TMP2]], [[TMP4]]
16 ; CHECK-NEXT: [[TMP6:%.*]] = bitcast double* [[TO:%.*]] to <2 x double>*
17 ; CHECK-NEXT: store <2 x double> [[TMP5]], <2 x double>* [[TMP6]], align 4
18 ; CHECK-NEXT: ret void
20 %from_1 = getelementptr double, double *%from, i64 1
21 %v0_1 = load double , double * %from
22 %v0_2 = load double , double * %from_1
23 %v1_1 = fadd double %v0_1, %v1
24 %v1_2 = fadd double %v2, %v0_2
25 %to_2 = getelementptr double, double * %to, i64 1
26 store double %v1_1, double *%to
27 store double %v1_2, double *%to_2
31 define void @vecload_vs_broadcast(double * noalias %from, double * noalias %to, double %v1, double %v2) {
32 ; CHECK-LABEL: @vecload_vs_broadcast(
34 ; CHECK-NEXT: br label [[LP:%.*]]
36 ; CHECK-NEXT: [[P:%.*]] = phi double [ 1.000000e+00, [[LP]] ], [ 0.000000e+00, [[ENTRY:%.*]] ]
37 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast double* [[FROM:%.*]] to <2 x double>*
38 ; CHECK-NEXT: [[TMP1:%.*]] = load <2 x double>, <2 x double>* [[TMP0]], align 4
39 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x double> poison, double [[P]], i32 0
40 ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <2 x double> [[TMP2]], <2 x double> [[TMP1]], <2 x i32> <i32 0, i32 2>
41 ; CHECK-NEXT: [[TMP4:%.*]] = fadd <2 x double> [[TMP1]], [[TMP3]]
42 ; CHECK-NEXT: [[TMP5:%.*]] = bitcast double* [[TO:%.*]] to <2 x double>*
43 ; CHECK-NEXT: store <2 x double> [[TMP4]], <2 x double>* [[TMP5]], align 4
44 ; CHECK-NEXT: br i1 undef, label [[LP]], label [[EXT:%.*]]
46 ; CHECK-NEXT: ret void
52 %p = phi double [ 1.000000e+00, %lp ], [ 0.000000e+00, %entry ]
53 %from_1 = getelementptr double, double *%from, i64 1
54 %v0_1 = load double , double * %from
55 %v0_2 = load double , double * %from_1
56 %v1_1 = fadd double %v0_1, %p
57 %v1_2 = fadd double %v0_1, %v0_2
58 %to_2 = getelementptr double, double * %to, i64 1
59 store double %v1_1, double *%to
60 store double %v1_2, double *%to_2
61 br i1 undef, label %lp, label %ext
67 define void @vecload_vs_broadcast2(double * noalias %from, double * noalias %to, double %v1, double %v2) {
68 ; CHECK-LABEL: @vecload_vs_broadcast2(
70 ; CHECK-NEXT: br label [[LP:%.*]]
72 ; CHECK-NEXT: [[P:%.*]] = phi double [ 1.000000e+00, [[LP]] ], [ 0.000000e+00, [[ENTRY:%.*]] ]
73 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast double* [[FROM:%.*]] to <2 x double>*
74 ; CHECK-NEXT: [[TMP1:%.*]] = load <2 x double>, <2 x double>* [[TMP0]], align 4
75 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x double> poison, double [[P]], i32 0
76 ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <2 x double> [[TMP2]], <2 x double> [[TMP1]], <2 x i32> <i32 0, i32 2>
77 ; CHECK-NEXT: [[TMP4:%.*]] = fadd <2 x double> [[TMP3]], [[TMP1]]
78 ; CHECK-NEXT: [[TMP5:%.*]] = bitcast double* [[TO:%.*]] to <2 x double>*
79 ; CHECK-NEXT: store <2 x double> [[TMP4]], <2 x double>* [[TMP5]], align 4
80 ; CHECK-NEXT: br i1 undef, label [[LP]], label [[EXT:%.*]]
82 ; CHECK-NEXT: ret void
88 %p = phi double [ 1.000000e+00, %lp ], [ 0.000000e+00, %entry ]
89 %from_1 = getelementptr double, double *%from, i64 1
90 %v0_1 = load double , double * %from
91 %v0_2 = load double , double * %from_1
92 %v1_1 = fadd double %p, %v0_1
93 %v1_2 = fadd double %v0_2, %v0_1
94 %to_2 = getelementptr double, double * %to, i64 1
95 store double %v1_1, double *%to
96 store double %v1_2, double *%to_2
97 br i1 undef, label %lp, label %ext
103 define void @vecload_vs_broadcast3(double * noalias %from, double * noalias %to, double %v1, double %v2) {
104 ; CHECK-LABEL: @vecload_vs_broadcast3(
106 ; CHECK-NEXT: br label [[LP:%.*]]
108 ; CHECK-NEXT: [[P:%.*]] = phi double [ 1.000000e+00, [[LP]] ], [ 0.000000e+00, [[ENTRY:%.*]] ]
109 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast double* [[FROM:%.*]] to <2 x double>*
110 ; CHECK-NEXT: [[TMP1:%.*]] = load <2 x double>, <2 x double>* [[TMP0]], align 4
111 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x double> poison, double [[P]], i32 0
112 ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <2 x double> [[TMP2]], <2 x double> [[TMP1]], <2 x i32> <i32 0, i32 2>
113 ; CHECK-NEXT: [[TMP4:%.*]] = fadd <2 x double> [[TMP3]], [[TMP1]]
114 ; CHECK-NEXT: [[TMP5:%.*]] = bitcast double* [[TO:%.*]] to <2 x double>*
115 ; CHECK-NEXT: store <2 x double> [[TMP4]], <2 x double>* [[TMP5]], align 4
116 ; CHECK-NEXT: br i1 undef, label [[LP]], label [[EXT:%.*]]
118 ; CHECK-NEXT: ret void
124 %p = phi double [ 1.000000e+00, %lp ], [ 0.000000e+00, %entry ]
125 %from_1 = getelementptr double, double *%from, i64 1
126 %v0_1 = load double , double * %from
127 %v0_2 = load double , double * %from_1
128 %v1_1 = fadd double %p, %v0_1
129 %v1_2 = fadd double %v0_1, %v0_2
130 %to_2 = getelementptr double, double * %to, i64 1
131 store double %v1_1, double *%to
132 store double %v1_2, double *%to_2
133 br i1 undef, label %lp, label %ext
139 define void @shuffle_nodes_match1(double * noalias %from, double * noalias %to, double %v1, double %v2) {
140 ; CHECK-LABEL: @shuffle_nodes_match1(
142 ; CHECK-NEXT: br label [[LP:%.*]]
144 ; CHECK-NEXT: [[P:%.*]] = phi double [ 1.000000e+00, [[LP]] ], [ 0.000000e+00, [[ENTRY:%.*]] ]
145 ; CHECK-NEXT: [[FROM_1:%.*]] = getelementptr double, double* [[FROM:%.*]], i32 1
146 ; CHECK-NEXT: [[V0_1:%.*]] = load double, double* [[FROM]], align 4
147 ; CHECK-NEXT: [[V0_2:%.*]] = load double, double* [[FROM_1]], align 4
148 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <2 x double> poison, double [[V0_2]], i32 0
149 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x double> [[TMP0]], double [[P]], i32 1
150 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x double> poison, double [[V0_1]], i32 0
151 ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <2 x double> [[TMP2]], <2 x double> poison, <2 x i32> zeroinitializer
152 ; CHECK-NEXT: [[TMP4:%.*]] = fadd <2 x double> [[TMP1]], [[TMP3]]
153 ; CHECK-NEXT: [[TMP5:%.*]] = bitcast double* [[TO:%.*]] to <2 x double>*
154 ; CHECK-NEXT: store <2 x double> [[TMP4]], <2 x double>* [[TMP5]], align 4
155 ; CHECK-NEXT: br i1 undef, label [[LP]], label [[EXT:%.*]]
157 ; CHECK-NEXT: ret void
163 %p = phi double [ 1.000000e+00, %lp ], [ 0.000000e+00, %entry ]
164 %from_1 = getelementptr double, double *%from, i64 1
165 %v0_1 = load double , double * %from
166 %v0_2 = load double , double * %from_1
167 %v1_1 = fadd double %v0_2, %v0_1
168 %v1_2 = fadd double %p, %v0_1
169 %to_2 = getelementptr double, double * %to, i64 1
170 store double %v1_1, double *%to
171 store double %v1_2, double *%to_2
172 br i1 undef, label %lp, label %ext
178 define void @vecload_vs_broadcast4(double * noalias %from, double * noalias %to, double %v1, double %v2) {
179 ; CHECK-LABEL: @vecload_vs_broadcast4(
181 ; CHECK-NEXT: br label [[LP:%.*]]
183 ; CHECK-NEXT: [[P:%.*]] = phi double [ 1.000000e+00, [[LP]] ], [ 0.000000e+00, [[ENTRY:%.*]] ]
184 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast double* [[FROM:%.*]] to <2 x double>*
185 ; CHECK-NEXT: [[TMP1:%.*]] = load <2 x double>, <2 x double>* [[TMP0]], align 4
186 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x double> [[TMP1]], double [[P]], i32 1
187 ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <2 x double> [[TMP1]], <2 x double> poison, <2 x i32> <i32 1, i32 0>
188 ; CHECK-NEXT: [[TMP4:%.*]] = fadd <2 x double> [[TMP2]], [[TMP3]]
189 ; CHECK-NEXT: [[TMP5:%.*]] = bitcast double* [[TO:%.*]] to <2 x double>*
190 ; CHECK-NEXT: store <2 x double> [[TMP4]], <2 x double>* [[TMP5]], align 4
191 ; CHECK-NEXT: br i1 undef, label [[LP]], label [[EXT:%.*]]
193 ; CHECK-NEXT: ret void
199 %p = phi double [ 1.000000e+00, %lp ], [ 0.000000e+00, %entry ]
200 %from_1 = getelementptr double, double *%from, i64 1
201 %v0_1 = load double , double * %from
202 %v0_2 = load double , double * %from_1
203 %v1_1 = fadd double %v0_1, %v0_2
204 %v1_2 = fadd double %p, %v0_1
205 %to_2 = getelementptr double, double * %to, i64 1
206 store double %v1_1, double *%to
207 store double %v1_2, double *%to_2
208 br i1 undef, label %lp, label %ext
215 define void @shuffle_nodes_match2(double * noalias %from, double * noalias %to, double %v1, double %v2) {
216 ; CHECK-LABEL: @shuffle_nodes_match2(
218 ; CHECK-NEXT: br label [[LP:%.*]]
220 ; CHECK-NEXT: [[P:%.*]] = phi double [ 1.000000e+00, [[LP]] ], [ 0.000000e+00, [[ENTRY:%.*]] ]
221 ; CHECK-NEXT: [[FROM_1:%.*]] = getelementptr double, double* [[FROM:%.*]], i32 1
222 ; CHECK-NEXT: [[V0_1:%.*]] = load double, double* [[FROM]], align 4
223 ; CHECK-NEXT: [[V0_2:%.*]] = load double, double* [[FROM_1]], align 4
224 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <2 x double> poison, double [[V0_1]], i32 0
225 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <2 x double> [[TMP0]], <2 x double> poison, <2 x i32> zeroinitializer
226 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x double> poison, double [[V0_2]], i32 0
227 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x double> [[TMP2]], double [[P]], i32 1
228 ; CHECK-NEXT: [[TMP4:%.*]] = fadd <2 x double> [[TMP1]], [[TMP3]]
229 ; CHECK-NEXT: [[TMP5:%.*]] = bitcast double* [[TO:%.*]] to <2 x double>*
230 ; CHECK-NEXT: store <2 x double> [[TMP4]], <2 x double>* [[TMP5]], align 4
231 ; CHECK-NEXT: br i1 undef, label [[LP]], label [[EXT:%.*]]
233 ; CHECK-NEXT: ret void
239 %p = phi double [ 1.000000e+00, %lp ], [ 0.000000e+00, %entry ]
240 %from_1 = getelementptr double, double *%from, i64 1
241 %v0_1 = load double , double * %from
242 %v0_2 = load double , double * %from_1
243 %v1_1 = fadd double %v0_1, %v0_2
244 %v1_2 = fadd double %v0_1, %p
245 %to_2 = getelementptr double, double * %to, i64 1
246 store double %v1_1, double *%to
247 store double %v1_2, double *%to_2
248 br i1 undef, label %lp, label %ext
254 ; Make sure we don't scramble operands when we reorder them and destroy
255 ; 'good' source order.
257 @a = common global [32000 x float] zeroinitializer, align 16
259 define void @good_load_order() {
260 ; CHECK-LABEL: @good_load_order(
262 ; CHECK-NEXT: br label [[FOR_COND1_PREHEADER:%.*]]
263 ; CHECK: for.cond1.preheader:
264 ; CHECK-NEXT: [[TMP0:%.*]] = load float, float* getelementptr inbounds ([32000 x float], [32000 x float]* @a, i32 0, i32 0), align 16
265 ; CHECK-NEXT: br label [[FOR_BODY3:%.*]]
267 ; CHECK-NEXT: [[TMP1:%.*]] = phi float [ [[TMP0]], [[FOR_COND1_PREHEADER]] ], [ [[TMP14:%.*]], [[FOR_BODY3]] ]
268 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[FOR_COND1_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY3]] ]
269 ; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[INDVARS_IV]] to i32
270 ; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[TMP2]], 1
271 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [32000 x float], [32000 x float]* @a, i32 0, i32 [[TMP3]]
272 ; CHECK-NEXT: [[TMP4:%.*]] = trunc i64 [[INDVARS_IV]] to i32
273 ; CHECK-NEXT: [[ARRAYIDX5:%.*]] = getelementptr inbounds [32000 x float], [32000 x float]* @a, i32 0, i32 [[TMP4]]
274 ; CHECK-NEXT: [[TMP5:%.*]] = trunc i64 [[INDVARS_IV]] to i32
275 ; CHECK-NEXT: [[TMP6:%.*]] = add i32 [[TMP5]], 4
276 ; CHECK-NEXT: [[ARRAYIDX31:%.*]] = getelementptr inbounds [32000 x float], [32000 x float]* @a, i32 0, i32 [[TMP6]]
277 ; CHECK-NEXT: [[TMP7:%.*]] = bitcast float* [[ARRAYIDX]] to <4 x float>*
278 ; CHECK-NEXT: [[TMP8:%.*]] = load <4 x float>, <4 x float>* [[TMP7]], align 4
279 ; CHECK-NEXT: [[TMP9:%.*]] = insertelement <4 x float> poison, float [[TMP1]], i32 0
280 ; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <4 x float> [[TMP9]], <4 x float> [[TMP8]], <4 x i32> <i32 0, i32 4, i32 5, i32 6>
281 ; CHECK-NEXT: [[TMP11:%.*]] = fmul <4 x float> [[TMP8]], [[TMP10]]
282 ; CHECK-NEXT: [[TMP12:%.*]] = bitcast float* [[ARRAYIDX5]] to <4 x float>*
283 ; CHECK-NEXT: store <4 x float> [[TMP11]], <4 x float>* [[TMP12]], align 4
284 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 5
285 ; CHECK-NEXT: [[TMP13:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
286 ; CHECK-NEXT: [[ARRAYIDX41:%.*]] = getelementptr inbounds [32000 x float], [32000 x float]* @a, i32 0, i32 [[TMP13]]
287 ; CHECK-NEXT: [[TMP14]] = load float, float* [[ARRAYIDX41]], align 4
288 ; CHECK-NEXT: [[TMP15:%.*]] = extractelement <4 x float> [[TMP8]], i32 3
289 ; CHECK-NEXT: [[MUL45:%.*]] = fmul float [[TMP14]], [[TMP15]]
290 ; CHECK-NEXT: store float [[MUL45]], float* [[ARRAYIDX31]], align 4
291 ; CHECK-NEXT: [[TMP16:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
292 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[TMP16]], 31995
293 ; CHECK-NEXT: br i1 [[CMP2]], label [[FOR_BODY3]], label [[FOR_END:%.*]]
295 ; CHECK-NEXT: ret void
298 br label %for.cond1.preheader
301 %0 = load float, float* getelementptr inbounds ([32000 x float], [32000 x float]* @a, i64 0, i64 0), align 16
305 %1 = phi float [ %0, %for.cond1.preheader ], [ %10, %for.body3 ]
306 %indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.body3 ]
307 %2 = add nsw i64 %indvars.iv, 1
308 %arrayidx = getelementptr inbounds [32000 x float], [32000 x float]* @a, i64 0, i64 %2
309 %3 = load float, float* %arrayidx, align 4
310 %arrayidx5 = getelementptr inbounds [32000 x float], [32000 x float]* @a, i64 0, i64 %indvars.iv
311 %mul6 = fmul float %3, %1
312 store float %mul6, float* %arrayidx5, align 4
313 %4 = add nsw i64 %indvars.iv, 2
314 %arrayidx11 = getelementptr inbounds [32000 x float], [32000 x float]* @a, i64 0, i64 %4
315 %5 = load float, float* %arrayidx11, align 4
316 %mul15 = fmul float %5, %3
317 store float %mul15, float* %arrayidx, align 4
318 %6 = add nsw i64 %indvars.iv, 3
319 %arrayidx21 = getelementptr inbounds [32000 x float], [32000 x float]* @a, i64 0, i64 %6
320 %7 = load float, float* %arrayidx21, align 4
321 %mul25 = fmul float %7, %5
322 store float %mul25, float* %arrayidx11, align 4
323 %8 = add nsw i64 %indvars.iv, 4
324 %arrayidx31 = getelementptr inbounds [32000 x float], [32000 x float]* @a, i64 0, i64 %8
325 %9 = load float, float* %arrayidx31, align 4
326 %mul35 = fmul float %9, %7
327 store float %mul35, float* %arrayidx21, align 4
328 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 5
329 %arrayidx41 = getelementptr inbounds [32000 x float], [32000 x float]* @a, i64 0, i64 %indvars.iv.next
330 %10 = load float, float* %arrayidx41, align 4
331 %mul45 = fmul float %10, %9
332 store float %mul45, float* %arrayidx31, align 4
333 %11 = trunc i64 %indvars.iv.next to i32
334 %cmp2 = icmp slt i32 %11, 31995
335 br i1 %cmp2, label %for.body3, label %for.end
341 ; Check vectorization of following code for double data type-
343 ; c[1] = b[1]+a[1]; // swapped b[1] and a[1]
345 define void @load_reorder_double(double* nocapture %c, double* noalias nocapture readonly %a, double* noalias nocapture readonly %b){
346 ; CHECK-LABEL: @load_reorder_double(
347 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast double* [[B:%.*]] to <2 x double>*
348 ; CHECK-NEXT: [[TMP2:%.*]] = load <2 x double>, <2 x double>* [[TMP1]], align 4
349 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast double* [[A:%.*]] to <2 x double>*
350 ; CHECK-NEXT: [[TMP4:%.*]] = load <2 x double>, <2 x double>* [[TMP3]], align 4
351 ; CHECK-NEXT: [[TMP5:%.*]] = fadd <2 x double> [[TMP4]], [[TMP2]]
352 ; CHECK-NEXT: [[TMP6:%.*]] = bitcast double* [[C:%.*]] to <2 x double>*
353 ; CHECK-NEXT: store <2 x double> [[TMP5]], <2 x double>* [[TMP6]], align 4
354 ; CHECK-NEXT: ret void
356 %1 = load double, double* %a
357 %2 = load double, double* %b
358 %3 = fadd double %1, %2
359 store double %3, double* %c
360 %4 = getelementptr inbounds double, double* %b, i64 1
361 %5 = load double, double* %4
362 %6 = getelementptr inbounds double, double* %a, i64 1
363 %7 = load double, double* %6
364 %8 = fadd double %5, %7
365 %9 = getelementptr inbounds double, double* %c, i64 1
366 store double %8, double* %9
370 ; Check vectorization of following code for float data type-
372 ; c[1] = b[1]+a[1]; // swapped b[1] and a[1]
376 define void @load_reorder_float(float* nocapture %c, float* noalias nocapture readonly %a, float* noalias nocapture readonly %b){
377 ; CHECK-LABEL: @load_reorder_float(
378 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast float* [[A:%.*]] to <4 x float>*
379 ; CHECK-NEXT: [[TMP2:%.*]] = load <4 x float>, <4 x float>* [[TMP1]], align 4
380 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast float* [[B:%.*]] to <4 x float>*
381 ; CHECK-NEXT: [[TMP4:%.*]] = load <4 x float>, <4 x float>* [[TMP3]], align 4
382 ; CHECK-NEXT: [[TMP5:%.*]] = fadd <4 x float> [[TMP2]], [[TMP4]]
383 ; CHECK-NEXT: [[TMP6:%.*]] = bitcast float* [[C:%.*]] to <4 x float>*
384 ; CHECK-NEXT: store <4 x float> [[TMP5]], <4 x float>* [[TMP6]], align 4
385 ; CHECK-NEXT: ret void
387 %1 = load float, float* %a
388 %2 = load float, float* %b
389 %3 = fadd float %1, %2
390 store float %3, float* %c
391 %4 = getelementptr inbounds float, float* %b, i64 1
392 %5 = load float, float* %4
393 %6 = getelementptr inbounds float, float* %a, i64 1
394 %7 = load float, float* %6
395 %8 = fadd float %5, %7
396 %9 = getelementptr inbounds float, float* %c, i64 1
397 store float %8, float* %9
398 %10 = getelementptr inbounds float, float* %a, i64 2
399 %11 = load float, float* %10
400 %12 = getelementptr inbounds float, float* %b, i64 2
401 %13 = load float, float* %12
402 %14 = fadd float %11, %13
403 %15 = getelementptr inbounds float, float* %c, i64 2
404 store float %14, float* %15
405 %16 = getelementptr inbounds float, float* %a, i64 3
406 %17 = load float, float* %16
407 %18 = getelementptr inbounds float, float* %b, i64 3
408 %19 = load float, float* %18
409 %20 = fadd float %17, %19
410 %21 = getelementptr inbounds float, float* %c, i64 3
411 store float %20, float* %21
415 ; Check we properly reorder the below code so that it gets vectorized optimally-
416 ; a[0] = (b[0]+c[0])+d[0];
417 ; a[1] = d[1]+(b[1]+c[1]);
418 ; a[2] = (b[2]+c[2])+d[2];
419 ; a[3] = (b[3]+c[3])+d[3];
421 define void @opcode_reorder(float* noalias nocapture %a, float* noalias nocapture readonly %b, float* noalias nocapture readonly %c,float* noalias nocapture readonly %d) {
422 ; CHECK-LABEL: @opcode_reorder(
423 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast float* [[B:%.*]] to <4 x float>*
424 ; CHECK-NEXT: [[TMP2:%.*]] = load <4 x float>, <4 x float>* [[TMP1]], align 4
425 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast float* [[C:%.*]] to <4 x float>*
426 ; CHECK-NEXT: [[TMP4:%.*]] = load <4 x float>, <4 x float>* [[TMP3]], align 4
427 ; CHECK-NEXT: [[TMP5:%.*]] = fadd <4 x float> [[TMP2]], [[TMP4]]
428 ; CHECK-NEXT: [[TMP6:%.*]] = bitcast float* [[D:%.*]] to <4 x float>*
429 ; CHECK-NEXT: [[TMP7:%.*]] = load <4 x float>, <4 x float>* [[TMP6]], align 4
430 ; CHECK-NEXT: [[TMP8:%.*]] = fadd <4 x float> [[TMP5]], [[TMP7]]
431 ; CHECK-NEXT: [[TMP9:%.*]] = bitcast float* [[A:%.*]] to <4 x float>*
432 ; CHECK-NEXT: store <4 x float> [[TMP8]], <4 x float>* [[TMP9]], align 4
433 ; CHECK-NEXT: ret void
435 %1 = load float, float* %b
436 %2 = load float, float* %c
437 %3 = fadd float %1, %2
438 %4 = load float, float* %d
439 %5 = fadd float %3, %4
440 store float %5, float* %a
441 %6 = getelementptr inbounds float, float* %d, i64 1
442 %7 = load float, float* %6
443 %8 = getelementptr inbounds float, float* %b, i64 1
444 %9 = load float, float* %8
445 %10 = getelementptr inbounds float, float* %c, i64 1
446 %11 = load float, float* %10
447 %12 = fadd float %9, %11
448 %13 = fadd float %7, %12
449 %14 = getelementptr inbounds float, float* %a, i64 1
450 store float %13, float* %14
451 %15 = getelementptr inbounds float, float* %b, i64 2
452 %16 = load float, float* %15
453 %17 = getelementptr inbounds float, float* %c, i64 2
454 %18 = load float, float* %17
455 %19 = fadd float %16, %18
456 %20 = getelementptr inbounds float, float* %d, i64 2
457 %21 = load float, float* %20
458 %22 = fadd float %19, %21
459 %23 = getelementptr inbounds float, float* %a, i64 2
460 store float %22, float* %23
461 %24 = getelementptr inbounds float, float* %b, i64 3
462 %25 = load float, float* %24
463 %26 = getelementptr inbounds float, float* %c, i64 3
464 %27 = load float, float* %26
465 %28 = fadd float %25, %27
466 %29 = getelementptr inbounds float, float* %d, i64 3
467 %30 = load float, float* %29
468 %31 = fadd float %28, %30
469 %32 = getelementptr inbounds float, float* %a, i64 3
470 store float %31, float* %32