1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=aarch64-eabi -mattr=+sve2 < %s | FileCheck %s
4 define float @add_f32(<vscale x 8 x float> %a, <vscale x 4 x float> %b) {
5 ; CHECK-LABEL: add_f32:
7 ; CHECK-NEXT: fadd z0.s, z0.s, z1.s
8 ; CHECK-NEXT: ptrue p0.s
9 ; CHECK-NEXT: fadd z0.s, z0.s, z2.s
10 ; CHECK-NEXT: faddv s0, p0, z0.s
11 ; CHECK-NEXT: // kill: def $s0 killed $s0 killed $z0
13 %r1 = call fast float @llvm.vector.reduce.fadd.f32.nxv8f32(float -0.0, <vscale x 8 x float> %a)
14 %r2 = call fast float @llvm.vector.reduce.fadd.f32.nxv4f32(float -0.0, <vscale x 4 x float> %b)
15 %r = fadd fast float %r1, %r2
19 ;define float @fmul_f32(<vscale x 8 x float> %a, <vscale x 4 x float> %b) {
20 ; %r1 = call fast float @llvm.vector.reduce.fmul.f32.nxv8f32(float 1.0, <vscale x 8 x float> %a)
21 ; %r2 = call fast float @llvm.vector.reduce.fmul.f32.nxv4f32(float 1.0, <vscale x 4 x float> %b)
22 ; %r = fmul fast float %r1, %r2
26 define float @fmin_f32(<vscale x 8 x float> %a, <vscale x 4 x float> %b) {
27 ; CHECK-LABEL: fmin_f32:
29 ; CHECK-NEXT: ptrue p0.s
30 ; CHECK-NEXT: fminnm z0.s, p0/m, z0.s, z1.s
31 ; CHECK-NEXT: fminnm z0.s, p0/m, z0.s, z2.s
32 ; CHECK-NEXT: fminnmv s0, p0, z0.s
33 ; CHECK-NEXT: // kill: def $s0 killed $s0 killed $z0
35 %r1 = call fast float @llvm.vector.reduce.fmin.nxv8f32(<vscale x 8 x float> %a)
36 %r2 = call fast float @llvm.vector.reduce.fmin.nxv4f32(<vscale x 4 x float> %b)
37 %r = call float @llvm.minnum.f32(float %r1, float %r2)
41 define float @fmax_f32(<vscale x 8 x float> %a, <vscale x 4 x float> %b) {
42 ; CHECK-LABEL: fmax_f32:
44 ; CHECK-NEXT: ptrue p0.s
45 ; CHECK-NEXT: fmaxnm z0.s, p0/m, z0.s, z1.s
46 ; CHECK-NEXT: fmaxnm z0.s, p0/m, z0.s, z2.s
47 ; CHECK-NEXT: fmaxnmv s0, p0, z0.s
48 ; CHECK-NEXT: // kill: def $s0 killed $s0 killed $z0
50 %r1 = call fast float @llvm.vector.reduce.fmax.nxv8f32(<vscale x 8 x float> %a)
51 %r2 = call fast float @llvm.vector.reduce.fmax.nxv4f32(<vscale x 4 x float> %b)
52 %r = call float @llvm.maxnum.f32(float %r1, float %r2)
56 define float @fminimum_f32(<vscale x 8 x float> %a, <vscale x 4 x float> %b) {
57 ; CHECK-LABEL: fminimum_f32:
59 ; CHECK-NEXT: ptrue p0.s
60 ; CHECK-NEXT: fmin z0.s, p0/m, z0.s, z1.s
61 ; CHECK-NEXT: fminv s1, p0, z2.s
62 ; CHECK-NEXT: fminv s0, p0, z0.s
63 ; CHECK-NEXT: fminnm s0, s0, s1
65 %r1 = call fast float @llvm.vector.reduce.fminimum.nxv8f32(<vscale x 8 x float> %a)
66 %r2 = call fast float @llvm.vector.reduce.fminimum.nxv4f32(<vscale x 4 x float> %b)
67 %r = call float @llvm.minnum.f32(float %r1, float %r2)
71 define float @fmaximum_f32(<vscale x 8 x float> %a, <vscale x 4 x float> %b) {
72 ; CHECK-LABEL: fmaximum_f32:
74 ; CHECK-NEXT: ptrue p0.s
75 ; CHECK-NEXT: fmax z0.s, p0/m, z0.s, z1.s
76 ; CHECK-NEXT: fmaxv s1, p0, z2.s
77 ; CHECK-NEXT: fmaxv s0, p0, z0.s
78 ; CHECK-NEXT: fmaxnm s0, s0, s1
80 %r1 = call fast float @llvm.vector.reduce.fmaximum.nxv8f32(<vscale x 8 x float> %a)
81 %r2 = call fast float @llvm.vector.reduce.fmaximum.nxv4f32(<vscale x 4 x float> %b)
82 %r = call float @llvm.maxnum.f32(float %r1, float %r2)
87 define i32 @add_i32(<vscale x 8 x i32> %a, <vscale x 4 x i32> %b) {
88 ; CHECK-LABEL: add_i32:
90 ; CHECK-NEXT: add z0.s, z0.s, z1.s
91 ; CHECK-NEXT: ptrue p0.s
92 ; CHECK-NEXT: add z0.s, z0.s, z2.s
93 ; CHECK-NEXT: uaddv d0, p0, z0.s
94 ; CHECK-NEXT: fmov x0, d0
95 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
97 %r1 = call i32 @llvm.vector.reduce.add.i32.nxv8i32(<vscale x 8 x i32> %a)
98 %r2 = call i32 @llvm.vector.reduce.add.i32.nxv4i32(<vscale x 4 x i32> %b)
103 define i16 @add_ext_i16(<vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
104 ; CHECK-LABEL: add_ext_i16:
106 ; CHECK-NEXT: uunpkhi z2.h, z0.b
107 ; CHECK-NEXT: uunpklo z0.h, z0.b
108 ; CHECK-NEXT: uunpkhi z3.h, z1.b
109 ; CHECK-NEXT: uunpklo z1.h, z1.b
110 ; CHECK-NEXT: ptrue p0.h
111 ; CHECK-NEXT: add z0.h, z0.h, z2.h
112 ; CHECK-NEXT: add z1.h, z1.h, z3.h
113 ; CHECK-NEXT: add z0.h, z0.h, z1.h
114 ; CHECK-NEXT: uaddv d0, p0, z0.h
115 ; CHECK-NEXT: fmov x0, d0
116 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
118 %ae = zext <vscale x 16 x i8> %a to <vscale x 16 x i16>
119 %be = zext <vscale x 16 x i8> %b to <vscale x 16 x i16>
120 %r1 = call i16 @llvm.vector.reduce.add.i16.nxv16i16(<vscale x 16 x i16> %ae)
121 %r2 = call i16 @llvm.vector.reduce.add.i16.nxv16i16(<vscale x 16 x i16> %be)
122 %r = add i16 %r1, %r2
126 define i16 @add_ext_v32i16(<vscale x 32 x i8> %a, <vscale x 16 x i8> %b) {
127 ; CHECK-LABEL: add_ext_v32i16:
129 ; CHECK-NEXT: uunpklo z3.h, z1.b
130 ; CHECK-NEXT: uunpklo z4.h, z0.b
131 ; CHECK-NEXT: uunpkhi z1.h, z1.b
132 ; CHECK-NEXT: uunpkhi z0.h, z0.b
133 ; CHECK-NEXT: uunpkhi z5.h, z2.b
134 ; CHECK-NEXT: uunpklo z2.h, z2.b
135 ; CHECK-NEXT: ptrue p0.h
136 ; CHECK-NEXT: add z0.h, z0.h, z1.h
137 ; CHECK-NEXT: add z1.h, z4.h, z3.h
138 ; CHECK-NEXT: add z0.h, z1.h, z0.h
139 ; CHECK-NEXT: add z1.h, z2.h, z5.h
140 ; CHECK-NEXT: add z0.h, z0.h, z1.h
141 ; CHECK-NEXT: uaddv d0, p0, z0.h
142 ; CHECK-NEXT: fmov x0, d0
143 ; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
145 %ae = zext <vscale x 32 x i8> %a to <vscale x 32 x i16>
146 %be = zext <vscale x 16 x i8> %b to <vscale x 16 x i16>
147 %r1 = call i16 @llvm.vector.reduce.add.i16.nxv32i16(<vscale x 32 x i16> %ae)
148 %r2 = call i16 @llvm.vector.reduce.add.i16.nxv16i16(<vscale x 16 x i16> %be)
149 %r = add i16 %r1, %r2
153 ;define i32 @mul_i32(<vscale x 8 x i32> %a, <vscale x 4 x i32> %b) {
154 ; %r1 = call i32 @llvm.vector.reduce.mul.i32.nxv8i32(<vscale x 8 x i32> %a)
155 ; %r2 = call i32 @llvm.vector.reduce.mul.i32.nxv4i32(<vscale x 4 x i32> %b)
156 ; %r = mul i32 %r1, %r2
160 define i32 @and_i32(<vscale x 8 x i32> %a, <vscale x 4 x i32> %b) {
161 ; CHECK-LABEL: and_i32:
163 ; CHECK-NEXT: and z0.d, z0.d, z1.d
164 ; CHECK-NEXT: ptrue p0.s
165 ; CHECK-NEXT: and z0.d, z0.d, z2.d
166 ; CHECK-NEXT: andv s0, p0, z0.s
167 ; CHECK-NEXT: fmov w0, s0
169 %r1 = call i32 @llvm.vector.reduce.and.i32.nxv8i32(<vscale x 8 x i32> %a)
170 %r2 = call i32 @llvm.vector.reduce.and.i32.nxv4i32(<vscale x 4 x i32> %b)
171 %r = and i32 %r1, %r2
175 define i32 @or_i32(<vscale x 8 x i32> %a, <vscale x 4 x i32> %b) {
176 ; CHECK-LABEL: or_i32:
178 ; CHECK-NEXT: orr z0.d, z0.d, z1.d
179 ; CHECK-NEXT: ptrue p0.s
180 ; CHECK-NEXT: orr z0.d, z0.d, z2.d
181 ; CHECK-NEXT: orv s0, p0, z0.s
182 ; CHECK-NEXT: fmov w0, s0
184 %r1 = call i32 @llvm.vector.reduce.or.i32.nxv8i32(<vscale x 8 x i32> %a)
185 %r2 = call i32 @llvm.vector.reduce.or.i32.nxv4i32(<vscale x 4 x i32> %b)
190 define i32 @xor_i32(<vscale x 8 x i32> %a, <vscale x 4 x i32> %b) {
191 ; CHECK-LABEL: xor_i32:
193 ; CHECK-NEXT: eor3 z0.d, z0.d, z1.d, z2.d
194 ; CHECK-NEXT: ptrue p0.s
195 ; CHECK-NEXT: eorv s0, p0, z0.s
196 ; CHECK-NEXT: fmov w0, s0
198 %r1 = call i32 @llvm.vector.reduce.xor.i32.nxv8i32(<vscale x 8 x i32> %a)
199 %r2 = call i32 @llvm.vector.reduce.xor.i32.nxv4i32(<vscale x 4 x i32> %b)
200 %r = xor i32 %r1, %r2
204 define i32 @umin_i32(<vscale x 8 x i32> %a, <vscale x 4 x i32> %b) {
205 ; CHECK-LABEL: umin_i32:
207 ; CHECK-NEXT: ptrue p0.s
208 ; CHECK-NEXT: umin z0.s, p0/m, z0.s, z1.s
209 ; CHECK-NEXT: umin z0.s, p0/m, z0.s, z2.s
210 ; CHECK-NEXT: uminv s0, p0, z0.s
211 ; CHECK-NEXT: fmov w0, s0
213 %r1 = call i32 @llvm.vector.reduce.umin.i32.nxv8i32(<vscale x 8 x i32> %a)
214 %r2 = call i32 @llvm.vector.reduce.umin.i32.nxv4i32(<vscale x 4 x i32> %b)
215 %r = call i32 @llvm.umin.i32(i32 %r1, i32 %r2)
219 define i32 @umax_i32(<vscale x 8 x i32> %a, <vscale x 4 x i32> %b) {
220 ; CHECK-LABEL: umax_i32:
222 ; CHECK-NEXT: ptrue p0.s
223 ; CHECK-NEXT: umax z0.s, p0/m, z0.s, z1.s
224 ; CHECK-NEXT: umax z0.s, p0/m, z0.s, z2.s
225 ; CHECK-NEXT: umaxv s0, p0, z0.s
226 ; CHECK-NEXT: fmov w0, s0
228 %r1 = call i32 @llvm.vector.reduce.umax.i32.nxv8i32(<vscale x 8 x i32> %a)
229 %r2 = call i32 @llvm.vector.reduce.umax.i32.nxv4i32(<vscale x 4 x i32> %b)
230 %r = call i32 @llvm.umax.i32(i32 %r1, i32 %r2)
234 define i32 @smin_i32(<vscale x 8 x i32> %a, <vscale x 4 x i32> %b) {
235 ; CHECK-LABEL: smin_i32:
237 ; CHECK-NEXT: ptrue p0.s
238 ; CHECK-NEXT: smin z0.s, p0/m, z0.s, z1.s
239 ; CHECK-NEXT: smin z0.s, p0/m, z0.s, z2.s
240 ; CHECK-NEXT: sminv s0, p0, z0.s
241 ; CHECK-NEXT: fmov w0, s0
243 %r1 = call i32 @llvm.vector.reduce.smin.i32.nxv8i32(<vscale x 8 x i32> %a)
244 %r2 = call i32 @llvm.vector.reduce.smin.i32.nxv4i32(<vscale x 4 x i32> %b)
245 %r = call i32 @llvm.smin.i32(i32 %r1, i32 %r2)
249 define i32 @smax_i32(<vscale x 8 x i32> %a, <vscale x 4 x i32> %b) {
250 ; CHECK-LABEL: smax_i32:
252 ; CHECK-NEXT: ptrue p0.s
253 ; CHECK-NEXT: smax z0.s, p0/m, z0.s, z1.s
254 ; CHECK-NEXT: smax z0.s, p0/m, z0.s, z2.s
255 ; CHECK-NEXT: smaxv s0, p0, z0.s
256 ; CHECK-NEXT: fmov w0, s0
258 %r1 = call i32 @llvm.vector.reduce.smax.i32.nxv8i32(<vscale x 8 x i32> %a)
259 %r2 = call i32 @llvm.vector.reduce.smax.i32.nxv4i32(<vscale x 4 x i32> %b)
260 %r = call i32 @llvm.smax.i32(i32 %r1, i32 %r2)
264 declare float @llvm.vector.reduce.fadd.f32.nxv8f32(float, <vscale x 8 x float>)
265 declare float @llvm.vector.reduce.fadd.f32.nxv4f32(float, <vscale x 4 x float>)
266 declare float @llvm.vector.reduce.fmul.f32.nxv8f32(float, <vscale x 8 x float>)
267 declare float @llvm.vector.reduce.fmul.f32.nxv4f32(float, <vscale x 4 x float>)
268 declare float @llvm.vector.reduce.fmin.nxv8f32(<vscale x 8 x float>)
269 declare float @llvm.vector.reduce.fmin.nxv4f32(<vscale x 4 x float>)
270 declare float @llvm.vector.reduce.fminimum.nxv8f32(<vscale x 8 x float>)
271 declare float @llvm.vector.reduce.fminimum.nxv4f32(<vscale x 4 x float>)
272 declare float @llvm.vector.reduce.fmax.nxv8f32(<vscale x 8 x float>)
273 declare float @llvm.vector.reduce.fmax.nxv4f32(<vscale x 4 x float>)
274 declare float @llvm.vector.reduce.fmaximum.nxv8f32(<vscale x 8 x float>)
275 declare float @llvm.vector.reduce.fmaximum.nxv4f32(<vscale x 4 x float>)
276 declare i32 @llvm.vector.reduce.add.i32.nxv8i32(<vscale x 8 x i32>)
277 declare i32 @llvm.vector.reduce.add.i32.nxv4i32(<vscale x 4 x i32>)
278 declare i16 @llvm.vector.reduce.add.i16.nxv32i16(<vscale x 32 x i16>)
279 declare i16 @llvm.vector.reduce.add.i16.nxv16i16(<vscale x 16 x i16>)
280 declare i32 @llvm.vector.reduce.mul.i32.nxv8i32(<vscale x 8 x i32>)
281 declare i32 @llvm.vector.reduce.mul.i32.nxv4i32(<vscale x 4 x i32>)
282 declare i32 @llvm.vector.reduce.and.i32.nxv8i32(<vscale x 8 x i32>)
283 declare i32 @llvm.vector.reduce.and.i32.nxv4i32(<vscale x 4 x i32>)
284 declare i32 @llvm.vector.reduce.or.i32.nxv8i32(<vscale x 8 x i32>)
285 declare i32 @llvm.vector.reduce.or.i32.nxv4i32(<vscale x 4 x i32>)
286 declare i32 @llvm.vector.reduce.xor.i32.nxv8i32(<vscale x 8 x i32>)
287 declare i32 @llvm.vector.reduce.xor.i32.nxv4i32(<vscale x 4 x i32>)
288 declare i32 @llvm.vector.reduce.umin.i32.nxv8i32(<vscale x 8 x i32>)
289 declare i32 @llvm.vector.reduce.umin.i32.nxv4i32(<vscale x 4 x i32>)
290 declare i32 @llvm.vector.reduce.umax.i32.nxv8i32(<vscale x 8 x i32>)
291 declare i32 @llvm.vector.reduce.umax.i32.nxv4i32(<vscale x 4 x i32>)
292 declare i32 @llvm.vector.reduce.smin.i32.nxv8i32(<vscale x 8 x i32>)
293 declare i32 @llvm.vector.reduce.smin.i32.nxv4i32(<vscale x 4 x i32>)
294 declare i32 @llvm.vector.reduce.smax.i32.nxv8i32(<vscale x 8 x i32>)
295 declare i32 @llvm.vector.reduce.smax.i32.nxv4i32(<vscale x 4 x i32>)
296 declare float @llvm.minnum.f32(float, float)
297 declare float @llvm.maxnum.f32(float, float)
298 declare float @llvm.minimum.f32(float, float)
299 declare float @llvm.maximum.f32(float, float)
300 declare i32 @llvm.umin.i32(i32, i32)
301 declare i32 @llvm.umax.i32(i32, i32)
302 declare i32 @llvm.smin.i32(i32, i32)
303 declare i32 @llvm.smax.i32(i32, i32)