1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -scoped-noalias-aa -slp-vectorizer -mtriple=x86_64-apple-darwin -enable-new-pm=false -S %s | FileCheck %s
3; RUN: opt -aa-pipeline='basic-aa,scoped-noalias-aa' -passes=slp-vectorizer -mtriple=x86_64-apple-darwin -S %s | FileCheck %s
4
5define void @version_multiple(i32* nocapture %out_block, i32* nocapture readonly %counter) {
6; CHECK-LABEL: @version_multiple(
7; CHECK-NEXT:  entry:
8; CHECK-NEXT:    [[TMP0:%.*]] = load i32, i32* [[COUNTER:%.*]], align 4
9; CHECK-NEXT:    [[TMP1:%.*]] = load i32, i32* [[OUT_BLOCK:%.*]], align 4
10; CHECK-NEXT:    [[XOR:%.*]] = xor i32 [[TMP1]], [[TMP0]]
11; CHECK-NEXT:    store i32 [[XOR]], i32* [[OUT_BLOCK]], align 4
12; CHECK-NEXT:    [[ARRAYIDX_1:%.*]] = getelementptr inbounds i32, i32* [[COUNTER]], i64 1
13; CHECK-NEXT:    [[TMP2:%.*]] = load i32, i32* [[ARRAYIDX_1]], align 4
14; CHECK-NEXT:    [[ARRAYIDX2_1:%.*]] = getelementptr inbounds i32, i32* [[OUT_BLOCK]], i64 1
15; CHECK-NEXT:    [[TMP3:%.*]] = load i32, i32* [[ARRAYIDX2_1]], align 4
16; CHECK-NEXT:    [[XOR_1:%.*]] = xor i32 [[TMP3]], [[TMP2]]
17; CHECK-NEXT:    store i32 [[XOR_1]], i32* [[ARRAYIDX2_1]], align 4
18; CHECK-NEXT:    [[ARRAYIDX_2:%.*]] = getelementptr inbounds i32, i32* [[COUNTER]], i64 2
19; CHECK-NEXT:    [[TMP4:%.*]] = load i32, i32* [[ARRAYIDX_2]], align 4
20; CHECK-NEXT:    [[ARRAYIDX2_2:%.*]] = getelementptr inbounds i32, i32* [[OUT_BLOCK]], i64 2
21; CHECK-NEXT:    [[TMP5:%.*]] = load i32, i32* [[ARRAYIDX2_2]], align 4
22; CHECK-NEXT:    [[XOR_2:%.*]] = xor i32 [[TMP5]], [[TMP4]]
23; CHECK-NEXT:    store i32 [[XOR_2]], i32* [[ARRAYIDX2_2]], align 4
24; CHECK-NEXT:    [[ARRAYIDX_3:%.*]] = getelementptr inbounds i32, i32* [[COUNTER]], i64 3
25; CHECK-NEXT:    [[TMP6:%.*]] = load i32, i32* [[ARRAYIDX_3]], align 4
26; CHECK-NEXT:    [[ARRAYIDX2_3:%.*]] = getelementptr inbounds i32, i32* [[OUT_BLOCK]], i64 3
27; CHECK-NEXT:    [[TMP7:%.*]] = load i32, i32* [[ARRAYIDX2_3]], align 4
28; CHECK-NEXT:    [[XOR_3:%.*]] = xor i32 [[TMP7]], [[TMP6]]
29; CHECK-NEXT:    store i32 [[XOR_3]], i32* [[ARRAYIDX2_3]], align 4
30; CHECK-NEXT:    ret void
31;
32entry:
33  %0 = load i32, i32* %counter, align 4
34  %1 = load i32, i32* %out_block, align 4
35  %xor = xor i32 %1, %0
36  store i32 %xor, i32* %out_block, align 4
37  %arrayidx.1 = getelementptr inbounds i32, i32* %counter, i64 1
38  %2 = load i32, i32* %arrayidx.1, align 4
39  %arrayidx2.1 = getelementptr inbounds i32, i32* %out_block, i64 1
40  %3 = load i32, i32* %arrayidx2.1, align 4
41  %xor.1 = xor i32 %3, %2
42  store i32 %xor.1, i32* %arrayidx2.1, align 4
43  %arrayidx.2 = getelementptr inbounds i32, i32* %counter, i64 2
44  %4 = load i32, i32* %arrayidx.2, align 4
45  %arrayidx2.2 = getelementptr inbounds i32, i32* %out_block, i64 2
46  %5 = load i32, i32* %arrayidx2.2, align 4
47  %xor.2 = xor i32 %5, %4
48  store i32 %xor.2, i32* %arrayidx2.2, align 4
49  %arrayidx.3 = getelementptr inbounds i32, i32* %counter, i64 3
50  %6 = load i32, i32* %arrayidx.3, align 4
51  %arrayidx2.3 = getelementptr inbounds i32, i32* %out_block, i64 3
52  %7 = load i32, i32* %arrayidx2.3, align 4
53  %xor.3 = xor i32 %7, %6
54  store i32 %xor.3, i32* %arrayidx2.3, align 4
55  ret void
56}
57
58declare void @use(<8 x float>)
59define void @delete_pointer_bound(float* %a, float* %b, i1 %c) #0 {
60; CHECK-LABEL: @delete_pointer_bound(
61; CHECK-NEXT:  entry:
62; CHECK-NEXT:    [[B_10:%.*]] = getelementptr inbounds float, float* [[B:%.*]], i64 10
63; CHECK-NEXT:    [[B_14:%.*]] = getelementptr inbounds float, float* [[B]], i64 14
64; CHECK-NEXT:    br i1 [[C:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
65; CHECK:       else:
66; CHECK-NEXT:    [[L0:%.*]] = load float, float* [[B_10]], align 4
67; CHECK-NEXT:    [[L1:%.*]] = load float, float* [[B_14]], align 4
68; CHECK-NEXT:    [[I2:%.*]] = insertelement <8 x float> undef, float [[L0]], i32 2
69; CHECK-NEXT:    [[I3:%.*]] = insertelement <8 x float> [[I2]], float [[L0]], i32 3
70; CHECK-NEXT:    [[I4:%.*]] = insertelement <8 x float> [[I3]], float [[L1]], i32 4
71; CHECK-NEXT:    [[I7:%.*]] = insertelement <8 x float> [[I4]], float [[L1]], i32 7
72; CHECK-NEXT:    call void @use(<8 x float> [[I7]])
73; CHECK-NEXT:    ret void
74; CHECK:       then:
75; CHECK-NEXT:    [[A_8:%.*]] = getelementptr inbounds float, float* [[A:%.*]], i64 8
76; CHECK-NEXT:    store float 0.000000e+00, float* [[A_8]], align 4
77; CHECK-NEXT:    [[L6:%.*]] = load float, float* [[B_14]], align 4
78; CHECK-NEXT:    [[A_5:%.*]] = getelementptr inbounds float, float* [[A]], i64 5
79; CHECK-NEXT:    store float [[L6]], float* [[A_5]], align 4
80; CHECK-NEXT:    [[A_6:%.*]] = getelementptr inbounds float, float* [[A]], i64 6
81; CHECK-NEXT:    store float 0.000000e+00, float* [[A_6]], align 4
82; CHECK-NEXT:    [[A_7:%.*]] = getelementptr inbounds float, float* [[A]], i64 7
83; CHECK-NEXT:    store float 0.000000e+00, float* [[A_7]], align 4
84; CHECK-NEXT:    ret void
85;
86entry:
87  %b.10 = getelementptr inbounds float, float* %b, i64 10
88  %b.14 = getelementptr inbounds float, float* %b, i64 14
89  br i1 %c, label %then, label %else
90
91else:
92  %l0 = load float, float* %b.10, align 4
93  %l1 = load float, float* %b.14, align 4
94  %i2 = insertelement <8 x float> undef, float %l0, i32 2
95  %i3 = insertelement <8 x float> %i2, float %l0, i32 3
96  %i4 = insertelement <8 x float> %i3, float %l1, i32 4
97  %i7 = insertelement <8 x float> %i4, float %l1, i32 7
98  call void @use(<8 x float> %i7)
99  ret void
100
101then:
102  %a.8 = getelementptr inbounds float, float* %a, i64 8
103  store float 0.0, float* %a.8, align 4
104  %l6 = load float, float* %b.14, align 4
105  %a.5 = getelementptr inbounds float, float* %a, i64 5
106  store float %l6, float* %a.5, align 4
107  %a.6 = getelementptr inbounds float, float* %a, i64 6
108  store float 0.0, float* %a.6, align 4
109  %a.7 = getelementptr inbounds float, float* %a, i64 7
110  store float 0.0, float* %a.7, align 4
111  ret void
112}
113
114%struct.zot = type { i16, i16, i16, i32, float, float, float, %struct.quux*, %struct.zot*, %struct.wombat*, %struct.wombat.0 }
115%struct.quux = type { i16, %struct.quux*, %struct.quux* }
116%struct.wombat = type { i32, i16, i8, i8, %struct.eggs* }
117%struct.eggs = type { float, i8, %struct.ham }
118%struct.ham = type { [2 x double], [8 x i8] }
119%struct.wombat.0 = type { %struct.bar }
120%struct.bar = type { [3 x double], [3 x double], double, double, i16, [3 x double]*, i32, [3 x double] }
121
122define double @preserve_loop_info(%struct.zot* %arg) {
123; CHECK-LABEL: @preserve_loop_info(
124; CHECK-NEXT:  entry:
125; CHECK-NEXT:    [[TMP:%.*]] = alloca [3 x double], align 16
126; CHECK-NEXT:    br label [[OUTER_HEADER:%.*]]
127; CHECK:       outer.header:
128; CHECK-NEXT:    br label [[INNER:%.*]]
129; CHECK:       inner:
130; CHECK-NEXT:    br i1 undef, label [[OUTER_LATCH:%.*]], label [[INNER]]
131; CHECK:       outer.latch:
132; CHECK-NEXT:    br i1 undef, label [[BB:%.*]], label [[OUTER_HEADER]]
133; CHECK:       bb:
134; CHECK-NEXT:    [[TMP5:%.*]] = load [3 x double]*, [3 x double]** undef, align 8
135; CHECK-NEXT:    [[TMP6:%.*]] = getelementptr inbounds [3 x double], [3 x double]* [[TMP]], i64 0, i64 0
136; CHECK-NEXT:    [[TMP7:%.*]] = getelementptr inbounds [3 x double], [3 x double]* [[TMP]], i64 0, i64 1
137; CHECK-NEXT:    br label [[LOOP_3HEADER:%.*]]
138; CHECK:       loop.3header:
139; CHECK-NEXT:    br i1 undef, label [[LOOP_3LATCH:%.*]], label [[BB9:%.*]]
140; CHECK:       bb9:
141; CHECK-NEXT:    [[TMP10:%.*]] = getelementptr inbounds [3 x double], [3 x double]* [[TMP5]], i64 undef, i64 1
142; CHECK-NEXT:    store double undef, double* [[TMP6]], align 16
143; CHECK-NEXT:    [[TMP12:%.*]] = load double, double* [[TMP10]], align 8
144; CHECK-NEXT:    store double [[TMP12]], double* [[TMP7]], align 8
145; CHECK-NEXT:    br label [[LOOP_3LATCH]]
146; CHECK:       loop.3latch:
147; CHECK-NEXT:    br i1 undef, label [[BB14:%.*]], label [[LOOP_3HEADER]]
148; CHECK:       bb14:
149; CHECK-NEXT:    [[TMP15:%.*]] = call double undef(double* [[TMP6]], %struct.zot* [[ARG:%.*]])
150; CHECK-NEXT:    ret double undef
151;
152entry:
153  %tmp = alloca [3 x double], align 16
154  br label %outer.header
155
156outer.header:                                              ; preds = %bb3, %bb
157  br label %inner
158
159inner:
160  br i1 undef, label %outer.latch, label %inner
161
162outer.latch:                                              ; preds = %bb16
163  br i1 undef, label %bb, label %outer.header
164
165bb:                                              ; preds = %bb3
166  %tmp5 = load [3 x double]*, [3 x double]** undef, align 8
167  %tmp6 = getelementptr inbounds [3 x double], [3 x double]* %tmp, i64 0, i64 0
168  %tmp7 = getelementptr inbounds [3 x double], [3 x double]* %tmp, i64 0, i64 1
169  br label %loop.3header
170
171loop.3header:                                              ; preds = %bb13, %bb4
172  br i1 undef, label %loop.3latch, label %bb9
173
174bb9:                                              ; preds = %bb8
175  %tmp10 = getelementptr inbounds [3 x double], [3 x double]* %tmp5, i64 undef, i64 1
176  store double undef, double* %tmp6, align 16
177  %tmp12 = load double, double* %tmp10, align 8
178  store double %tmp12, double* %tmp7, align 8
179  br label %loop.3latch
180
181loop.3latch:                                             ; preds = %bb11, %bb8
182  br i1 undef, label %bb14, label %loop.3header
183
184bb14:                                             ; preds = %bb13
185  %tmp15 = call double undef(double* %tmp6, %struct.zot* %arg)
186  ret double undef
187}
188
189define void @gather_sequence_crash(<2 x float> %arg, float* %arg1, float %arg2, float* %arg3, float* %arg4, float* %arg5, i1 %c.1, i1 %c.2) {
190; CHECK-LABEL: @gather_sequence_crash(
191; CHECK-NEXT:  bb:
192; CHECK-NEXT:    br i1 [[C_1:%.*]], label [[BB16:%.*]], label [[BB6:%.*]]
193; CHECK:       bb6:
194; CHECK-NEXT:    [[TMP:%.*]] = getelementptr inbounds float, float* [[ARG1:%.*]], i32 4
195; CHECK-NEXT:    [[TMP7:%.*]] = getelementptr inbounds float, float* [[ARG1]], i32 5
196; CHECK-NEXT:    [[TMP8:%.*]] = getelementptr inbounds float, float* [[ARG1]], i32 3
197; CHECK-NEXT:    [[TMP9:%.*]] = getelementptr inbounds float, float* [[ARG1]], i32 6
198; CHECK-NEXT:    [[TMP0:%.*]] = insertelement <4 x float> <float poison, float poison, float poison, float 0.000000e+00>, float [[ARG2:%.*]], i32 0
199; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <2 x float> [[ARG:%.*]], <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
200; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <4 x float> [[TMP0]], <4 x float> [[TMP1]], <4 x i32> <i32 0, i32 4, i32 5, i32 3>
201; CHECK-NEXT:    [[TMP3:%.*]] = fmul <4 x float> [[TMP2]], zeroinitializer
202; CHECK-NEXT:    [[TMP4:%.*]] = bitcast float* [[TMP8]] to <4 x float>*
203; CHECK-NEXT:    store <4 x float> [[TMP3]], <4 x float>* [[TMP4]], align 4
204; CHECK-NEXT:    ret void
205; CHECK:       bb16:
206; CHECK-NEXT:    br label [[BB17:%.*]]
207; CHECK:       bb17:
208; CHECK-NEXT:    br label [[BB18:%.*]]
209; CHECK:       bb18:
210; CHECK-NEXT:    br label [[BB19:%.*]]
211; CHECK:       bb19:
212; CHECK-NEXT:    br label [[BB20:%.*]]
213; CHECK:       bb20:
214; CHECK-NEXT:    br label [[BB21:%.*]]
215; CHECK:       bb21:
216; CHECK-NEXT:    br label [[BB22:%.*]]
217; CHECK:       bb22:
218; CHECK-NEXT:    [[TMP23:%.*]] = getelementptr inbounds float, float* [[ARG4:%.*]], i32 0
219; CHECK-NEXT:    [[TMP24:%.*]] = getelementptr float, float* [[TMP23]], i64 7
220; CHECK-NEXT:    br i1 [[C_2:%.*]], label [[BB25:%.*]], label [[BB22]]
221; CHECK:       bb25:
222; CHECK-NEXT:    [[TMP26:%.*]] = getelementptr float, float* [[TMP23]], i64 6
223; CHECK-NEXT:    store float 0.000000e+00, float* [[TMP24]], align 4
224; CHECK-NEXT:    [[TMP27:%.*]] = load float, float* [[ARG5:%.*]], align 4
225; CHECK-NEXT:    [[TMP28:%.*]] = getelementptr float, float* [[TMP23]], i64 5
226; CHECK-NEXT:    [[TMP29:%.*]] = fadd float 0.000000e+00, 0.000000e+00
227; CHECK-NEXT:    store float 0.000000e+00, float* [[TMP26]], align 4
228; CHECK-NEXT:    [[TMP30:%.*]] = getelementptr float, float* [[TMP23]], i64 4
229; CHECK-NEXT:    store float 0.000000e+00, float* [[TMP28]], align 4
230; CHECK-NEXT:    [[TMP31:%.*]] = fadd float 0.000000e+00, 0.000000e+00
231; CHECK-NEXT:    store float 0.000000e+00, float* [[TMP30]], align 4
232; CHECK-NEXT:    [[TMP32:%.*]] = getelementptr inbounds float, float* [[ARG4]], i32 0
233; CHECK-NEXT:    br label [[BB33:%.*]]
234; CHECK:       bb33:
235; CHECK-NEXT:    br label [[BB34:%.*]]
236; CHECK:       bb34:
237; CHECK-NEXT:    [[TMP35:%.*]] = getelementptr float, float* [[TMP32]], i64 3
238; CHECK-NEXT:    [[TMP36:%.*]] = getelementptr float, float* [[TMP32]], i64 2
239; CHECK-NEXT:    [[TMP37:%.*]] = load float, float* [[TMP35]], align 4
240; CHECK-NEXT:    [[TMP38:%.*]] = fadd float 0.000000e+00, [[TMP37]]
241; CHECK-NEXT:    store float [[TMP38]], float* [[TMP35]], align 4
242; CHECK-NEXT:    [[TMP39:%.*]] = getelementptr float, float* [[TMP32]], i64 1
243; CHECK-NEXT:    [[TMP40:%.*]] = load float, float* [[TMP36]], align 4
244; CHECK-NEXT:    [[TMP41:%.*]] = fadd float 0.000000e+00, [[TMP40]]
245; CHECK-NEXT:    store float [[TMP41]], float* [[TMP36]], align 4
246; CHECK-NEXT:    [[TMP42:%.*]] = load float, float* [[TMP39]], align 4
247; CHECK-NEXT:    [[TMP43:%.*]] = fadd float 0.000000e+00, [[TMP42]]
248; CHECK-NEXT:    store float [[TMP43]], float* [[TMP39]], align 4
249; CHECK-NEXT:    [[TMP44:%.*]] = load float, float* [[ARG3:%.*]], align 4
250; CHECK-NEXT:    [[TMP45:%.*]] = load float, float* [[TMP32]], align 4
251; CHECK-NEXT:    [[TMP46:%.*]] = fadd float 0.000000e+00, [[TMP45]]
252; CHECK-NEXT:    store float [[TMP46]], float* [[TMP32]], align 4
253; CHECK-NEXT:    call void @quux()
254; CHECK-NEXT:    br label [[BB47:%.*]]
255; CHECK:       bb47:
256; CHECK-NEXT:    br label [[BB17]]
257;
258bb:
259  br i1 %c.1, label %bb16, label %bb6
260
261bb6:                                              ; preds = %bb
262  %tmp = getelementptr inbounds float, float* %arg1, i32 4
263  %tmp7 = getelementptr inbounds float, float* %arg1, i32 5
264  %tmp8 = getelementptr inbounds float, float* %arg1, i32 3
265  %tmp9 = getelementptr inbounds float, float* %arg1, i32 6
266  %tmp10 = extractelement <2 x float> %arg, i32 0
267  %tmp11 = fmul float %tmp10, 0.000000e+00
268  store float %tmp11, float* %tmp, align 4
269  %tmp12 = extractelement <2 x float> %arg, i32 1
270  %tmp13 = fmul float %tmp12, 0.000000e+00
271  store float %tmp13, float* %tmp7, align 4
272  %tmp14 = fmul float %arg2, 0.000000e+00
273  store float %tmp14, float* %tmp8, align 4
274  %tmp15 = fmul float 0.000000e+00, 0.000000e+00
275  store float %tmp15, float* %tmp9, align 4
276  ret void
277
278bb16:                                             ; preds = %bb
279  br label %bb17
280
281bb17:                                             ; preds = %bb47, %bb16
282  br label %bb18
283
284bb18:                                             ; preds = %bb17
285  br label %bb19
286
287bb19:                                             ; preds = %bb18
288  br label %bb20
289
290bb20:                                             ; preds = %bb19
291  br label %bb21
292
293bb21:                                             ; preds = %bb20
294  br label %bb22
295
296bb22:                                             ; preds = %bb22, %bb21
297  %tmp23 = getelementptr inbounds float, float* %arg4, i32 0
298  %tmp24 = getelementptr float, float* %tmp23, i64 7
299  br i1 %c.2, label %bb25, label %bb22
300
301bb25:                                             ; preds = %bb22
302  %tmp26 = getelementptr float, float* %tmp23, i64 6
303  store float 0.000000e+00, float* %tmp24, align 4
304  %tmp27 = load float, float* %arg5, align 4
305  %tmp28 = getelementptr float, float* %tmp23, i64 5
306  %tmp29 = fadd float 0.000000e+00, 0.000000e+00
307  store float 0.000000e+00, float* %tmp26, align 4
308  %tmp30 = getelementptr float, float* %tmp23, i64 4
309  store float 0.000000e+00, float* %tmp28, align 4
310  %tmp31 = fadd float 0.000000e+00, 0.000000e+00
311  store float 0.000000e+00, float* %tmp30, align 4
312  %tmp32 = getelementptr inbounds float, float* %arg4, i32 0
313  br label %bb33
314
315bb33:                                             ; preds = %bb25
316  br label %bb34
317
318bb34:                                             ; preds = %bb33
319  %tmp35 = getelementptr float, float* %tmp32, i64 3
320  %tmp36 = getelementptr float, float* %tmp32, i64 2
321  %tmp37 = load float, float* %tmp35, align 4
322  %tmp38 = fadd float 0.000000e+00, %tmp37
323  store float %tmp38, float* %tmp35, align 4
324  %tmp39 = getelementptr float, float* %tmp32, i64 1
325  %tmp40 = load float, float* %tmp36, align 4
326  %tmp41 = fadd float 0.000000e+00, %tmp40
327  store float %tmp41, float* %tmp36, align 4
328  %tmp42 = load float, float* %tmp39, align 4
329  %tmp43 = fadd float 0.000000e+00, %tmp42
330  store float %tmp43, float* %tmp39, align 4
331  %tmp44 = load float, float* %arg3, align 4
332  %tmp45 = load float, float* %tmp32, align 4
333  %tmp46 = fadd float 0.000000e+00, %tmp45
334  store float %tmp46, float* %tmp32, align 4
335  call void @quux()
336  br label %bb47
337
338bb47:                                             ; preds = %bb34
339  br label %bb17
340}
341
342declare void @quux()
343attributes #0 = { "target-features"="+avx2" }
344