1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zvfh,+v -target-abi=ilp32d \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,ZVFH
4 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zvfh,+v -target-abi=lp64d \
5 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,ZVFH
6 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zvfhmin,+v -target-abi=ilp32d \
7 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,ZVFHMIN
8 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zvfhmin,+v -target-abi=lp64d \
9 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,ZVFHMIN
11 declare <2 x half> @llvm.vp.fabs.v2f16(<2 x half>, <2 x i1>, i32)
13 define <2 x half> @vfabs_vv_v2f16(<2 x half> %va, <2 x i1> %m, i32 zeroext %evl) {
14 ; ZVFH-LABEL: vfabs_vv_v2f16:
16 ; ZVFH-NEXT: vsetvli zero, a0, e16, mf4, ta, ma
17 ; ZVFH-NEXT: vfabs.v v8, v8, v0.t
20 ; ZVFHMIN-LABEL: vfabs_vv_v2f16:
22 ; ZVFHMIN-NEXT: lui a1, 8
23 ; ZVFHMIN-NEXT: addi a1, a1, -1
24 ; ZVFHMIN-NEXT: vsetvli zero, a0, e16, mf4, ta, ma
25 ; ZVFHMIN-NEXT: vand.vx v8, v8, a1, v0.t
27 %v = call <2 x half> @llvm.vp.fabs.v2f16(<2 x half> %va, <2 x i1> %m, i32 %evl)
31 define <2 x half> @vfabs_vv_v2f16_unmasked(<2 x half> %va, i32 zeroext %evl) {
32 ; ZVFH-LABEL: vfabs_vv_v2f16_unmasked:
34 ; ZVFH-NEXT: vsetvli zero, a0, e16, mf4, ta, ma
35 ; ZVFH-NEXT: vfabs.v v8, v8
38 ; ZVFHMIN-LABEL: vfabs_vv_v2f16_unmasked:
40 ; ZVFHMIN-NEXT: lui a1, 8
41 ; ZVFHMIN-NEXT: addi a1, a1, -1
42 ; ZVFHMIN-NEXT: vsetvli zero, a0, e16, mf4, ta, ma
43 ; ZVFHMIN-NEXT: vand.vx v8, v8, a1
45 %v = call <2 x half> @llvm.vp.fabs.v2f16(<2 x half> %va, <2 x i1> splat (i1 true), i32 %evl)
49 declare <4 x half> @llvm.vp.fabs.v4f16(<4 x half>, <4 x i1>, i32)
51 define <4 x half> @vfabs_vv_v4f16(<4 x half> %va, <4 x i1> %m, i32 zeroext %evl) {
52 ; ZVFH-LABEL: vfabs_vv_v4f16:
54 ; ZVFH-NEXT: vsetvli zero, a0, e16, mf2, ta, ma
55 ; ZVFH-NEXT: vfabs.v v8, v8, v0.t
58 ; ZVFHMIN-LABEL: vfabs_vv_v4f16:
60 ; ZVFHMIN-NEXT: lui a1, 8
61 ; ZVFHMIN-NEXT: addi a1, a1, -1
62 ; ZVFHMIN-NEXT: vsetvli zero, a0, e16, mf2, ta, ma
63 ; ZVFHMIN-NEXT: vand.vx v8, v8, a1, v0.t
65 %v = call <4 x half> @llvm.vp.fabs.v4f16(<4 x half> %va, <4 x i1> %m, i32 %evl)
69 define <4 x half> @vfabs_vv_v4f16_unmasked(<4 x half> %va, i32 zeroext %evl) {
70 ; ZVFH-LABEL: vfabs_vv_v4f16_unmasked:
72 ; ZVFH-NEXT: vsetvli zero, a0, e16, mf2, ta, ma
73 ; ZVFH-NEXT: vfabs.v v8, v8
76 ; ZVFHMIN-LABEL: vfabs_vv_v4f16_unmasked:
78 ; ZVFHMIN-NEXT: lui a1, 8
79 ; ZVFHMIN-NEXT: addi a1, a1, -1
80 ; ZVFHMIN-NEXT: vsetvli zero, a0, e16, mf2, ta, ma
81 ; ZVFHMIN-NEXT: vand.vx v8, v8, a1
83 %v = call <4 x half> @llvm.vp.fabs.v4f16(<4 x half> %va, <4 x i1> splat (i1 true), i32 %evl)
87 declare <8 x half> @llvm.vp.fabs.v8f16(<8 x half>, <8 x i1>, i32)
89 define <8 x half> @vfabs_vv_v8f16(<8 x half> %va, <8 x i1> %m, i32 zeroext %evl) {
90 ; ZVFH-LABEL: vfabs_vv_v8f16:
92 ; ZVFH-NEXT: vsetvli zero, a0, e16, m1, ta, ma
93 ; ZVFH-NEXT: vfabs.v v8, v8, v0.t
96 ; ZVFHMIN-LABEL: vfabs_vv_v8f16:
98 ; ZVFHMIN-NEXT: lui a1, 8
99 ; ZVFHMIN-NEXT: addi a1, a1, -1
100 ; ZVFHMIN-NEXT: vsetvli zero, a0, e16, m1, ta, ma
101 ; ZVFHMIN-NEXT: vand.vx v8, v8, a1, v0.t
103 %v = call <8 x half> @llvm.vp.fabs.v8f16(<8 x half> %va, <8 x i1> %m, i32 %evl)
107 define <8 x half> @vfabs_vv_v8f16_unmasked(<8 x half> %va, i32 zeroext %evl) {
108 ; ZVFH-LABEL: vfabs_vv_v8f16_unmasked:
110 ; ZVFH-NEXT: vsetvli zero, a0, e16, m1, ta, ma
111 ; ZVFH-NEXT: vfabs.v v8, v8
114 ; ZVFHMIN-LABEL: vfabs_vv_v8f16_unmasked:
116 ; ZVFHMIN-NEXT: lui a1, 8
117 ; ZVFHMIN-NEXT: addi a1, a1, -1
118 ; ZVFHMIN-NEXT: vsetvli zero, a0, e16, m1, ta, ma
119 ; ZVFHMIN-NEXT: vand.vx v8, v8, a1
121 %v = call <8 x half> @llvm.vp.fabs.v8f16(<8 x half> %va, <8 x i1> splat (i1 true), i32 %evl)
125 declare <16 x half> @llvm.vp.fabs.v16f16(<16 x half>, <16 x i1>, i32)
127 define <16 x half> @vfabs_vv_v16f16(<16 x half> %va, <16 x i1> %m, i32 zeroext %evl) {
128 ; ZVFH-LABEL: vfabs_vv_v16f16:
130 ; ZVFH-NEXT: vsetvli zero, a0, e16, m2, ta, ma
131 ; ZVFH-NEXT: vfabs.v v8, v8, v0.t
134 ; ZVFHMIN-LABEL: vfabs_vv_v16f16:
136 ; ZVFHMIN-NEXT: lui a1, 8
137 ; ZVFHMIN-NEXT: addi a1, a1, -1
138 ; ZVFHMIN-NEXT: vsetvli zero, a0, e16, m2, ta, ma
139 ; ZVFHMIN-NEXT: vand.vx v8, v8, a1, v0.t
141 %v = call <16 x half> @llvm.vp.fabs.v16f16(<16 x half> %va, <16 x i1> %m, i32 %evl)
145 define <16 x half> @vfabs_vv_v16f16_unmasked(<16 x half> %va, i32 zeroext %evl) {
146 ; ZVFH-LABEL: vfabs_vv_v16f16_unmasked:
148 ; ZVFH-NEXT: vsetvli zero, a0, e16, m2, ta, ma
149 ; ZVFH-NEXT: vfabs.v v8, v8
152 ; ZVFHMIN-LABEL: vfabs_vv_v16f16_unmasked:
154 ; ZVFHMIN-NEXT: lui a1, 8
155 ; ZVFHMIN-NEXT: addi a1, a1, -1
156 ; ZVFHMIN-NEXT: vsetvli zero, a0, e16, m2, ta, ma
157 ; ZVFHMIN-NEXT: vand.vx v8, v8, a1
159 %v = call <16 x half> @llvm.vp.fabs.v16f16(<16 x half> %va, <16 x i1> splat (i1 true), i32 %evl)
163 declare <2 x float> @llvm.vp.fabs.v2f32(<2 x float>, <2 x i1>, i32)
165 define <2 x float> @vfabs_vv_v2f32(<2 x float> %va, <2 x i1> %m, i32 zeroext %evl) {
166 ; CHECK-LABEL: vfabs_vv_v2f32:
168 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
169 ; CHECK-NEXT: vfabs.v v8, v8, v0.t
171 %v = call <2 x float> @llvm.vp.fabs.v2f32(<2 x float> %va, <2 x i1> %m, i32 %evl)
175 define <2 x float> @vfabs_vv_v2f32_unmasked(<2 x float> %va, i32 zeroext %evl) {
176 ; CHECK-LABEL: vfabs_vv_v2f32_unmasked:
178 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
179 ; CHECK-NEXT: vfabs.v v8, v8
181 %v = call <2 x float> @llvm.vp.fabs.v2f32(<2 x float> %va, <2 x i1> splat (i1 true), i32 %evl)
185 declare <4 x float> @llvm.vp.fabs.v4f32(<4 x float>, <4 x i1>, i32)
187 define <4 x float> @vfabs_vv_v4f32(<4 x float> %va, <4 x i1> %m, i32 zeroext %evl) {
188 ; CHECK-LABEL: vfabs_vv_v4f32:
190 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
191 ; CHECK-NEXT: vfabs.v v8, v8, v0.t
193 %v = call <4 x float> @llvm.vp.fabs.v4f32(<4 x float> %va, <4 x i1> %m, i32 %evl)
197 define <4 x float> @vfabs_vv_v4f32_unmasked(<4 x float> %va, i32 zeroext %evl) {
198 ; CHECK-LABEL: vfabs_vv_v4f32_unmasked:
200 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
201 ; CHECK-NEXT: vfabs.v v8, v8
203 %v = call <4 x float> @llvm.vp.fabs.v4f32(<4 x float> %va, <4 x i1> splat (i1 true), i32 %evl)
207 declare <8 x float> @llvm.vp.fabs.v8f32(<8 x float>, <8 x i1>, i32)
209 define <8 x float> @vfabs_vv_v8f32(<8 x float> %va, <8 x i1> %m, i32 zeroext %evl) {
210 ; CHECK-LABEL: vfabs_vv_v8f32:
212 ; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma
213 ; CHECK-NEXT: vfabs.v v8, v8, v0.t
215 %v = call <8 x float> @llvm.vp.fabs.v8f32(<8 x float> %va, <8 x i1> %m, i32 %evl)
219 define <8 x float> @vfabs_vv_v8f32_unmasked(<8 x float> %va, i32 zeroext %evl) {
220 ; CHECK-LABEL: vfabs_vv_v8f32_unmasked:
222 ; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma
223 ; CHECK-NEXT: vfabs.v v8, v8
225 %v = call <8 x float> @llvm.vp.fabs.v8f32(<8 x float> %va, <8 x i1> splat (i1 true), i32 %evl)
229 declare <16 x float> @llvm.vp.fabs.v16f32(<16 x float>, <16 x i1>, i32)
231 define <16 x float> @vfabs_vv_v16f32(<16 x float> %va, <16 x i1> %m, i32 zeroext %evl) {
232 ; CHECK-LABEL: vfabs_vv_v16f32:
234 ; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma
235 ; CHECK-NEXT: vfabs.v v8, v8, v0.t
237 %v = call <16 x float> @llvm.vp.fabs.v16f32(<16 x float> %va, <16 x i1> %m, i32 %evl)
241 define <16 x float> @vfabs_vv_v16f32_unmasked(<16 x float> %va, i32 zeroext %evl) {
242 ; CHECK-LABEL: vfabs_vv_v16f32_unmasked:
244 ; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma
245 ; CHECK-NEXT: vfabs.v v8, v8
247 %v = call <16 x float> @llvm.vp.fabs.v16f32(<16 x float> %va, <16 x i1> splat (i1 true), i32 %evl)
251 declare <2 x double> @llvm.vp.fabs.v2f64(<2 x double>, <2 x i1>, i32)
253 define <2 x double> @vfabs_vv_v2f64(<2 x double> %va, <2 x i1> %m, i32 zeroext %evl) {
254 ; CHECK-LABEL: vfabs_vv_v2f64:
256 ; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma
257 ; CHECK-NEXT: vfabs.v v8, v8, v0.t
259 %v = call <2 x double> @llvm.vp.fabs.v2f64(<2 x double> %va, <2 x i1> %m, i32 %evl)
263 define <2 x double> @vfabs_vv_v2f64_unmasked(<2 x double> %va, i32 zeroext %evl) {
264 ; CHECK-LABEL: vfabs_vv_v2f64_unmasked:
266 ; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma
267 ; CHECK-NEXT: vfabs.v v8, v8
269 %v = call <2 x double> @llvm.vp.fabs.v2f64(<2 x double> %va, <2 x i1> splat (i1 true), i32 %evl)
273 declare <4 x double> @llvm.vp.fabs.v4f64(<4 x double>, <4 x i1>, i32)
275 define <4 x double> @vfabs_vv_v4f64(<4 x double> %va, <4 x i1> %m, i32 zeroext %evl) {
276 ; CHECK-LABEL: vfabs_vv_v4f64:
278 ; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma
279 ; CHECK-NEXT: vfabs.v v8, v8, v0.t
281 %v = call <4 x double> @llvm.vp.fabs.v4f64(<4 x double> %va, <4 x i1> %m, i32 %evl)
285 define <4 x double> @vfabs_vv_v4f64_unmasked(<4 x double> %va, i32 zeroext %evl) {
286 ; CHECK-LABEL: vfabs_vv_v4f64_unmasked:
288 ; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma
289 ; CHECK-NEXT: vfabs.v v8, v8
291 %v = call <4 x double> @llvm.vp.fabs.v4f64(<4 x double> %va, <4 x i1> splat (i1 true), i32 %evl)
295 declare <8 x double> @llvm.vp.fabs.v8f64(<8 x double>, <8 x i1>, i32)
297 define <8 x double> @vfabs_vv_v8f64(<8 x double> %va, <8 x i1> %m, i32 zeroext %evl) {
298 ; CHECK-LABEL: vfabs_vv_v8f64:
300 ; CHECK-NEXT: vsetvli zero, a0, e64, m4, ta, ma
301 ; CHECK-NEXT: vfabs.v v8, v8, v0.t
303 %v = call <8 x double> @llvm.vp.fabs.v8f64(<8 x double> %va, <8 x i1> %m, i32 %evl)
307 define <8 x double> @vfabs_vv_v8f64_unmasked(<8 x double> %va, i32 zeroext %evl) {
308 ; CHECK-LABEL: vfabs_vv_v8f64_unmasked:
310 ; CHECK-NEXT: vsetvli zero, a0, e64, m4, ta, ma
311 ; CHECK-NEXT: vfabs.v v8, v8
313 %v = call <8 x double> @llvm.vp.fabs.v8f64(<8 x double> %va, <8 x i1> splat (i1 true), i32 %evl)
317 declare <15 x double> @llvm.vp.fabs.v15f64(<15 x double>, <15 x i1>, i32)
319 define <15 x double> @vfabs_vv_v15f64(<15 x double> %va, <15 x i1> %m, i32 zeroext %evl) {
320 ; CHECK-LABEL: vfabs_vv_v15f64:
322 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
323 ; CHECK-NEXT: vfabs.v v8, v8, v0.t
325 %v = call <15 x double> @llvm.vp.fabs.v15f64(<15 x double> %va, <15 x i1> %m, i32 %evl)
329 define <15 x double> @vfabs_vv_v15f64_unmasked(<15 x double> %va, i32 zeroext %evl) {
330 ; CHECK-LABEL: vfabs_vv_v15f64_unmasked:
332 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
333 ; CHECK-NEXT: vfabs.v v8, v8
335 %v = call <15 x double> @llvm.vp.fabs.v15f64(<15 x double> %va, <15 x i1> splat (i1 true), i32 %evl)
339 declare <16 x double> @llvm.vp.fabs.v16f64(<16 x double>, <16 x i1>, i32)
341 define <16 x double> @vfabs_vv_v16f64(<16 x double> %va, <16 x i1> %m, i32 zeroext %evl) {
342 ; CHECK-LABEL: vfabs_vv_v16f64:
344 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
345 ; CHECK-NEXT: vfabs.v v8, v8, v0.t
347 %v = call <16 x double> @llvm.vp.fabs.v16f64(<16 x double> %va, <16 x i1> %m, i32 %evl)
351 define <16 x double> @vfabs_vv_v16f64_unmasked(<16 x double> %va, i32 zeroext %evl) {
352 ; CHECK-LABEL: vfabs_vv_v16f64_unmasked:
354 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
355 ; CHECK-NEXT: vfabs.v v8, v8
357 %v = call <16 x double> @llvm.vp.fabs.v16f64(<16 x double> %va, <16 x i1> splat (i1 true), i32 %evl)
361 declare <32 x double> @llvm.vp.fabs.v32f64(<32 x double>, <32 x i1>, i32)
363 define <32 x double> @vfabs_vv_v32f64(<32 x double> %va, <32 x i1> %m, i32 zeroext %evl) {
364 ; CHECK-LABEL: vfabs_vv_v32f64:
366 ; CHECK-NEXT: li a2, 16
367 ; CHECK-NEXT: vsetivli zero, 2, e8, mf4, ta, ma
368 ; CHECK-NEXT: vslidedown.vi v24, v0, 2
369 ; CHECK-NEXT: mv a1, a0
370 ; CHECK-NEXT: bltu a0, a2, .LBB26_2
371 ; CHECK-NEXT: # %bb.1:
372 ; CHECK-NEXT: li a1, 16
373 ; CHECK-NEXT: .LBB26_2:
374 ; CHECK-NEXT: vsetvli zero, a1, e64, m8, ta, ma
375 ; CHECK-NEXT: vfabs.v v8, v8, v0.t
376 ; CHECK-NEXT: addi a1, a0, -16
377 ; CHECK-NEXT: sltu a0, a0, a1
378 ; CHECK-NEXT: addi a0, a0, -1
379 ; CHECK-NEXT: and a0, a0, a1
380 ; CHECK-NEXT: vmv1r.v v0, v24
381 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
382 ; CHECK-NEXT: vfabs.v v16, v16, v0.t
384 %v = call <32 x double> @llvm.vp.fabs.v32f64(<32 x double> %va, <32 x i1> %m, i32 %evl)
388 define <32 x double> @vfabs_vv_v32f64_unmasked(<32 x double> %va, i32 zeroext %evl) {
389 ; CHECK-LABEL: vfabs_vv_v32f64_unmasked:
391 ; CHECK-NEXT: li a2, 16
392 ; CHECK-NEXT: mv a1, a0
393 ; CHECK-NEXT: bltu a0, a2, .LBB27_2
394 ; CHECK-NEXT: # %bb.1:
395 ; CHECK-NEXT: li a1, 16
396 ; CHECK-NEXT: .LBB27_2:
397 ; CHECK-NEXT: vsetvli zero, a1, e64, m8, ta, ma
398 ; CHECK-NEXT: vfabs.v v8, v8
399 ; CHECK-NEXT: addi a1, a0, -16
400 ; CHECK-NEXT: sltu a0, a0, a1
401 ; CHECK-NEXT: addi a0, a0, -1
402 ; CHECK-NEXT: and a0, a0, a1
403 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
404 ; CHECK-NEXT: vfabs.v v16, v16
406 %v = call <32 x double> @llvm.vp.fabs.v32f64(<32 x double> %va, <32 x i1> splat (i1 true), i32 %evl)