1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=aarch64-eabi < %s | FileCheck %s
4 define float @add_f32(<8 x float> %a, <4 x float> %b) {
5 ; CHECK-LABEL: add_f32:
7 ; CHECK-NEXT: fadd v0.4s, v0.4s, v1.4s
8 ; CHECK-NEXT: fadd v0.4s, v0.4s, v2.4s
9 ; CHECK-NEXT: faddp v0.4s, v0.4s, v0.4s
10 ; CHECK-NEXT: faddp s0, v0.2s
12 %r1 = call fast float @llvm.vector.reduce.fadd.f32.v8f32(float -0.0, <8 x float> %a)
13 %r2 = call fast float @llvm.vector.reduce.fadd.f32.v4f32(float -0.0, <4 x float> %b)
14 %r = fadd fast float %r1, %r2
18 define float @fmul_f32(<8 x float> %a, <4 x float> %b) {
19 ; CHECK-LABEL: fmul_f32:
21 ; CHECK-NEXT: fmul v0.4s, v0.4s, v1.4s
22 ; CHECK-NEXT: fmul v0.4s, v0.4s, v2.4s
23 ; CHECK-NEXT: ext v1.16b, v0.16b, v0.16b, #8
24 ; CHECK-NEXT: fmul v0.2s, v0.2s, v1.2s
25 ; CHECK-NEXT: fmul s0, s0, v0.s[1]
27 %r1 = call fast float @llvm.vector.reduce.fmul.f32.v8f32(float 1.0, <8 x float> %a)
28 %r2 = call fast float @llvm.vector.reduce.fmul.f32.v4f32(float 1.0, <4 x float> %b)
29 %r = fmul fast float %r1, %r2
33 define float @fmin_f32(<8 x float> %a, <4 x float> %b) {
34 ; CHECK-LABEL: fmin_f32:
36 ; CHECK-NEXT: fminnm v0.4s, v0.4s, v1.4s
37 ; CHECK-NEXT: fminnm v0.4s, v0.4s, v2.4s
38 ; CHECK-NEXT: fminnmv s0, v0.4s
40 %r1 = call float @llvm.vector.reduce.fmin.v8f32(<8 x float> %a)
41 %r2 = call float @llvm.vector.reduce.fmin.v4f32(<4 x float> %b)
42 %r = call float @llvm.minnum.f32(float %r1, float %r2)
46 define float @fmax_f32(<8 x float> %a, <4 x float> %b) {
47 ; CHECK-LABEL: fmax_f32:
49 ; CHECK-NEXT: fmaxnm v0.4s, v0.4s, v1.4s
50 ; CHECK-NEXT: fmaxnm v0.4s, v0.4s, v2.4s
51 ; CHECK-NEXT: fmaxnmv s0, v0.4s
53 %r1 = call float @llvm.vector.reduce.fmax.v8f32(<8 x float> %a)
54 %r2 = call float @llvm.vector.reduce.fmax.v4f32(<4 x float> %b)
55 %r = call float @llvm.maxnum.f32(float %r1, float %r2)
59 define float @fminimum_f32(<8 x float> %a, <4 x float> %b) {
60 ; CHECK-LABEL: fminimum_f32:
62 ; CHECK-NEXT: fmin v0.4s, v0.4s, v1.4s
63 ; CHECK-NEXT: fmin v0.4s, v0.4s, v2.4s
64 ; CHECK-NEXT: fminv s0, v0.4s
66 %r1 = call float @llvm.vector.reduce.fminimum.v8f32(<8 x float> %a)
67 %r2 = call float @llvm.vector.reduce.fminimum.v4f32(<4 x float> %b)
68 %r = call float @llvm.minimum.f32(float %r1, float %r2)
72 define float @fmaximum_f32(<8 x float> %a, <4 x float> %b) {
73 ; CHECK-LABEL: fmaximum_f32:
75 ; CHECK-NEXT: fmax v0.4s, v0.4s, v1.4s
76 ; CHECK-NEXT: fmax v0.4s, v0.4s, v2.4s
77 ; CHECK-NEXT: fmaxv s0, v0.4s
79 %r1 = call float @llvm.vector.reduce.fmaximum.v8f32(<8 x float> %a)
80 %r2 = call float @llvm.vector.reduce.fmaximum.v4f32(<4 x float> %b)
81 %r = call float @llvm.maximum.f32(float %r1, float %r2)
85 ; These next two tests have incorrect minnum/minimum combinations
86 define float @fminimumnum_f32(<8 x float> %a, <4 x float> %b) {
87 ; CHECK-LABEL: fminimumnum_f32:
89 ; CHECK-NEXT: fmin v0.4s, v0.4s, v1.4s
90 ; CHECK-NEXT: fminv s1, v2.4s
91 ; CHECK-NEXT: fminv s0, v0.4s
92 ; CHECK-NEXT: fminnm s0, s0, s1
94 %r1 = call float @llvm.vector.reduce.fminimum.v8f32(<8 x float> %a)
95 %r2 = call float @llvm.vector.reduce.fminimum.v4f32(<4 x float> %b)
96 %r = call float @llvm.minnum.f32(float %r1, float %r2)
100 define float @fmaxnumimum_f32(<8 x float> %a, <4 x float> %b) {
101 ; CHECK-LABEL: fmaxnumimum_f32:
103 ; CHECK-NEXT: fmaxnm v0.4s, v0.4s, v1.4s
104 ; CHECK-NEXT: fmaxnmv s1, v2.4s
105 ; CHECK-NEXT: fmaxnmv s0, v0.4s
106 ; CHECK-NEXT: fmax s0, s0, s1
108 %r1 = call float @llvm.vector.reduce.fmax.v8f32(<8 x float> %a)
109 %r2 = call float @llvm.vector.reduce.fmax.v4f32(<4 x float> %b)
110 %r = call float @llvm.maximum.f32(float %r1, float %r2)
115 define i32 @add_i32(<8 x i32> %a, <4 x i32> %b) {
116 ; CHECK-LABEL: add_i32:
118 ; CHECK-NEXT: add v0.4s, v0.4s, v1.4s
119 ; CHECK-NEXT: add v0.4s, v0.4s, v2.4s
120 ; CHECK-NEXT: addv s0, v0.4s
121 ; CHECK-NEXT: fmov w0, s0
123 %r1 = call i32 @llvm.vector.reduce.add.i32.v8i32(<8 x i32> %a)
124 %r2 = call i32 @llvm.vector.reduce.add.i32.v4i32(<4 x i32> %b)
125 %r = add i32 %r1, %r2
129 define i16 @add_ext_i16(<16 x i8> %a, <16 x i8> %b) {
130 ; CHECK-LABEL: add_ext_i16:
132 ; CHECK-NEXT: uaddlp v1.8h, v1.16b
133 ; CHECK-NEXT: uadalp v1.8h, v0.16b
134 ; CHECK-NEXT: addv h0, v1.8h
135 ; CHECK-NEXT: fmov w0, s0
137 %ae = zext <16 x i8> %a to <16 x i16>
138 %be = zext <16 x i8> %b to <16 x i16>
139 %r1 = call i16 @llvm.vector.reduce.add.i16.v16i16(<16 x i16> %ae)
140 %r2 = call i16 @llvm.vector.reduce.add.i16.v16i16(<16 x i16> %be)
141 %r = add i16 %r1, %r2
145 define i16 @add_ext_v32i16(<32 x i8> %a, <16 x i8> %b) {
146 ; CHECK-LABEL: add_ext_v32i16:
148 ; CHECK-NEXT: uaddl2 v3.8h, v0.16b, v1.16b
149 ; CHECK-NEXT: uaddl v0.8h, v0.8b, v1.8b
150 ; CHECK-NEXT: add v0.8h, v0.8h, v3.8h
151 ; CHECK-NEXT: uadalp v0.8h, v2.16b
152 ; CHECK-NEXT: addv h0, v0.8h
153 ; CHECK-NEXT: fmov w0, s0
155 %ae = zext <32 x i8> %a to <32 x i16>
156 %be = zext <16 x i8> %b to <16 x i16>
157 %r1 = call i16 @llvm.vector.reduce.add.i16.v32i16(<32 x i16> %ae)
158 %r2 = call i16 @llvm.vector.reduce.add.i16.v16i16(<16 x i16> %be)
159 %r = add i16 %r1, %r2
163 define i32 @mul_i32(<8 x i32> %a, <4 x i32> %b) {
164 ; CHECK-LABEL: mul_i32:
166 ; CHECK-NEXT: mul v0.4s, v0.4s, v1.4s
167 ; CHECK-NEXT: mul v0.4s, v0.4s, v2.4s
168 ; CHECK-NEXT: ext v1.16b, v0.16b, v0.16b, #8
169 ; CHECK-NEXT: mul v0.2s, v0.2s, v1.2s
170 ; CHECK-NEXT: mov w8, v0.s[1]
171 ; CHECK-NEXT: fmov w9, s0
172 ; CHECK-NEXT: mul w0, w9, w8
174 %r1 = call i32 @llvm.vector.reduce.mul.i32.v8i32(<8 x i32> %a)
175 %r2 = call i32 @llvm.vector.reduce.mul.i32.v4i32(<4 x i32> %b)
176 %r = mul i32 %r1, %r2
180 define i32 @and_i32(<8 x i32> %a, <4 x i32> %b) {
181 ; CHECK-LABEL: and_i32:
183 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
184 ; CHECK-NEXT: and v0.16b, v0.16b, v2.16b
185 ; CHECK-NEXT: ext v1.16b, v0.16b, v0.16b, #8
186 ; CHECK-NEXT: and v0.8b, v0.8b, v1.8b
187 ; CHECK-NEXT: fmov x8, d0
188 ; CHECK-NEXT: lsr x9, x8, #32
189 ; CHECK-NEXT: and w0, w8, w9
191 %r1 = call i32 @llvm.vector.reduce.and.i32.v8i32(<8 x i32> %a)
192 %r2 = call i32 @llvm.vector.reduce.and.i32.v4i32(<4 x i32> %b)
193 %r = and i32 %r1, %r2
197 define i32 @or_i32(<8 x i32> %a, <4 x i32> %b) {
198 ; CHECK-LABEL: or_i32:
200 ; CHECK-NEXT: orr v0.16b, v0.16b, v1.16b
201 ; CHECK-NEXT: orr v0.16b, v0.16b, v2.16b
202 ; CHECK-NEXT: ext v1.16b, v0.16b, v0.16b, #8
203 ; CHECK-NEXT: orr v0.8b, v0.8b, v1.8b
204 ; CHECK-NEXT: fmov x8, d0
205 ; CHECK-NEXT: lsr x9, x8, #32
206 ; CHECK-NEXT: orr w0, w8, w9
208 %r1 = call i32 @llvm.vector.reduce.or.i32.v8i32(<8 x i32> %a)
209 %r2 = call i32 @llvm.vector.reduce.or.i32.v4i32(<4 x i32> %b)
214 define i32 @xor_i32(<8 x i32> %a, <4 x i32> %b) {
215 ; CHECK-LABEL: xor_i32:
217 ; CHECK-NEXT: eor v0.16b, v0.16b, v1.16b
218 ; CHECK-NEXT: eor v0.16b, v0.16b, v2.16b
219 ; CHECK-NEXT: ext v1.16b, v0.16b, v0.16b, #8
220 ; CHECK-NEXT: eor v0.8b, v0.8b, v1.8b
221 ; CHECK-NEXT: fmov x8, d0
222 ; CHECK-NEXT: lsr x9, x8, #32
223 ; CHECK-NEXT: eor w0, w8, w9
225 %r1 = call i32 @llvm.vector.reduce.xor.i32.v8i32(<8 x i32> %a)
226 %r2 = call i32 @llvm.vector.reduce.xor.i32.v4i32(<4 x i32> %b)
227 %r = xor i32 %r1, %r2
231 define i32 @umin_i32(<8 x i32> %a, <4 x i32> %b) {
232 ; CHECK-LABEL: umin_i32:
234 ; CHECK-NEXT: umin v0.4s, v0.4s, v1.4s
235 ; CHECK-NEXT: umin v0.4s, v0.4s, v2.4s
236 ; CHECK-NEXT: uminv s0, v0.4s
237 ; CHECK-NEXT: fmov w0, s0
239 %r1 = call i32 @llvm.vector.reduce.umin.i32.v8i32(<8 x i32> %a)
240 %r2 = call i32 @llvm.vector.reduce.umin.i32.v4i32(<4 x i32> %b)
241 %r = call i32 @llvm.umin.i32(i32 %r1, i32 %r2)
245 define i32 @umax_i32(<8 x i32> %a, <4 x i32> %b) {
246 ; CHECK-LABEL: umax_i32:
248 ; CHECK-NEXT: umax v0.4s, v0.4s, v1.4s
249 ; CHECK-NEXT: umax v0.4s, v0.4s, v2.4s
250 ; CHECK-NEXT: umaxv s0, v0.4s
251 ; CHECK-NEXT: fmov w0, s0
253 %r1 = call i32 @llvm.vector.reduce.umax.i32.v8i32(<8 x i32> %a)
254 %r2 = call i32 @llvm.vector.reduce.umax.i32.v4i32(<4 x i32> %b)
255 %r = call i32 @llvm.umax.i32(i32 %r1, i32 %r2)
259 define i32 @smin_i32(<8 x i32> %a, <4 x i32> %b) {
260 ; CHECK-LABEL: smin_i32:
262 ; CHECK-NEXT: smin v0.4s, v0.4s, v1.4s
263 ; CHECK-NEXT: smin v0.4s, v0.4s, v2.4s
264 ; CHECK-NEXT: sminv s0, v0.4s
265 ; CHECK-NEXT: fmov w0, s0
267 %r1 = call i32 @llvm.vector.reduce.smin.i32.v8i32(<8 x i32> %a)
268 %r2 = call i32 @llvm.vector.reduce.smin.i32.v4i32(<4 x i32> %b)
269 %r = call i32 @llvm.smin.i32(i32 %r1, i32 %r2)
273 define i32 @smax_i32(<8 x i32> %a, <4 x i32> %b) {
274 ; CHECK-LABEL: smax_i32:
276 ; CHECK-NEXT: smax v0.4s, v0.4s, v1.4s
277 ; CHECK-NEXT: smax v0.4s, v0.4s, v2.4s
278 ; CHECK-NEXT: smaxv s0, v0.4s
279 ; CHECK-NEXT: fmov w0, s0
281 %r1 = call i32 @llvm.vector.reduce.smax.i32.v8i32(<8 x i32> %a)
282 %r2 = call i32 @llvm.vector.reduce.smax.i32.v4i32(<4 x i32> %b)
283 %r = call i32 @llvm.smax.i32(i32 %r1, i32 %r2)
287 declare float @llvm.vector.reduce.fadd.f32.v8f32(float, <8 x float>)
288 declare float @llvm.vector.reduce.fadd.f32.v4f32(float, <4 x float>)
289 declare float @llvm.vector.reduce.fmul.f32.v8f32(float, <8 x float>)
290 declare float @llvm.vector.reduce.fmul.f32.v4f32(float, <4 x float>)
291 declare float @llvm.vector.reduce.fmin.v8f32(<8 x float>)
292 declare float @llvm.vector.reduce.fmin.v4f32(<4 x float>)
293 declare float @llvm.vector.reduce.fmax.v8f32(<8 x float>)
294 declare float @llvm.vector.reduce.fmax.v4f32(<4 x float>)
295 declare float @llvm.vector.reduce.fminimum.v8f32(<8 x float>)
296 declare float @llvm.vector.reduce.fminimum.v4f32(<4 x float>)
297 declare float @llvm.vector.reduce.fmaximum.v8f32(<8 x float>)
298 declare float @llvm.vector.reduce.fmaximum.v4f32(<4 x float>)
299 declare i32 @llvm.vector.reduce.add.i32.v8i32(<8 x i32>)
300 declare i32 @llvm.vector.reduce.add.i32.v4i32(<4 x i32>)
301 declare i16 @llvm.vector.reduce.add.i16.v32i16(<32 x i16>)
302 declare i16 @llvm.vector.reduce.add.i16.v16i16(<16 x i16>)
303 declare i32 @llvm.vector.reduce.mul.i32.v8i32(<8 x i32>)
304 declare i32 @llvm.vector.reduce.mul.i32.v4i32(<4 x i32>)
305 declare i32 @llvm.vector.reduce.and.i32.v8i32(<8 x i32>)
306 declare i32 @llvm.vector.reduce.and.i32.v4i32(<4 x i32>)
307 declare i32 @llvm.vector.reduce.or.i32.v8i32(<8 x i32>)
308 declare i32 @llvm.vector.reduce.or.i32.v4i32(<4 x i32>)
309 declare i32 @llvm.vector.reduce.xor.i32.v8i32(<8 x i32>)
310 declare i32 @llvm.vector.reduce.xor.i32.v4i32(<4 x i32>)
311 declare i32 @llvm.vector.reduce.umin.i32.v8i32(<8 x i32>)
312 declare i32 @llvm.vector.reduce.umin.i32.v4i32(<4 x i32>)
313 declare i32 @llvm.vector.reduce.umax.i32.v8i32(<8 x i32>)
314 declare i32 @llvm.vector.reduce.umax.i32.v4i32(<4 x i32>)
315 declare i32 @llvm.vector.reduce.smin.i32.v8i32(<8 x i32>)
316 declare i32 @llvm.vector.reduce.smin.i32.v4i32(<4 x i32>)
317 declare i32 @llvm.vector.reduce.smax.i32.v8i32(<8 x i32>)
318 declare i32 @llvm.vector.reduce.smax.i32.v4i32(<4 x i32>)
319 declare float @llvm.minnum.f32(float, float)
320 declare float @llvm.maxnum.f32(float, float)
321 declare float @llvm.minimum.f32(float, float)
322 declare float @llvm.maximum.f32(float, float)
323 declare i32 @llvm.umin.i32(i32, i32)
324 declare i32 @llvm.umax.i32(i32, i32)
325 declare i32 @llvm.smin.i32(i32, i32)
326 declare i32 @llvm.smax.i32(i32, i32)