1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+m,+d,+zfh,+zvfh,+v -target-abi=ilp32d \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+m,+d,+zfh,+zvfh,+v -target-abi=lp64d \
5 ; RUN: -verify-machineinstrs < %s | FileCheck %s
7 declare <2 x half> @llvm.vp.copysign.v2f16(<2 x half>, <2 x half>, <2 x i1>, i32)
9 define <2 x half> @vfsgnj_vv_v2f16(<2 x half> %va, <2 x half> %vb, <2 x i1> %m, i32 zeroext %evl) {
10 ; CHECK-LABEL: vfsgnj_vv_v2f16:
12 ; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, ma
13 ; CHECK-NEXT: vfsgnj.vv v8, v8, v9, v0.t
15 %v = call <2 x half> @llvm.vp.copysign.v2f16(<2 x half> %va, <2 x half> %vb, <2 x i1> %m, i32 %evl)
19 define <2 x half> @vfsgnj_vv_v2f16_unmasked(<2 x half> %va, <2 x half> %vb, i32 zeroext %evl) {
20 ; CHECK-LABEL: vfsgnj_vv_v2f16_unmasked:
22 ; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, ma
23 ; CHECK-NEXT: vfsgnj.vv v8, v8, v9
25 %head = insertelement <2 x i1> poison, i1 true, i32 0
26 %m = shufflevector <2 x i1> %head, <2 x i1> poison, <2 x i32> zeroinitializer
27 %v = call <2 x half> @llvm.vp.copysign.v2f16(<2 x half> %va, <2 x half> %vb, <2 x i1> %m, i32 %evl)
31 declare <4 x half> @llvm.vp.copysign.v4f16(<4 x half>, <4 x half>, <4 x i1>, i32)
33 define <4 x half> @vfsgnj_vv_v4f16(<4 x half> %va, <4 x half> %vb, <4 x i1> %m, i32 zeroext %evl) {
34 ; CHECK-LABEL: vfsgnj_vv_v4f16:
36 ; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, ma
37 ; CHECK-NEXT: vfsgnj.vv v8, v8, v9, v0.t
39 %v = call <4 x half> @llvm.vp.copysign.v4f16(<4 x half> %va, <4 x half> %vb, <4 x i1> %m, i32 %evl)
43 define <4 x half> @vfsgnj_vv_v4f16_unmasked(<4 x half> %va, <4 x half> %vb, i32 zeroext %evl) {
44 ; CHECK-LABEL: vfsgnj_vv_v4f16_unmasked:
46 ; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, ma
47 ; CHECK-NEXT: vfsgnj.vv v8, v8, v9
49 %head = insertelement <4 x i1> poison, i1 true, i32 0
50 %m = shufflevector <4 x i1> %head, <4 x i1> poison, <4 x i32> zeroinitializer
51 %v = call <4 x half> @llvm.vp.copysign.v4f16(<4 x half> %va, <4 x half> %vb, <4 x i1> %m, i32 %evl)
55 declare <8 x half> @llvm.vp.copysign.v8f16(<8 x half>, <8 x half>, <8 x i1>, i32)
57 define <8 x half> @vfsgnj_vv_v8f16(<8 x half> %va, <8 x half> %vb, <8 x i1> %m, i32 zeroext %evl) {
58 ; CHECK-LABEL: vfsgnj_vv_v8f16:
60 ; CHECK-NEXT: vsetvli zero, a0, e16, m1, ta, ma
61 ; CHECK-NEXT: vfsgnj.vv v8, v8, v9, v0.t
63 %v = call <8 x half> @llvm.vp.copysign.v8f16(<8 x half> %va, <8 x half> %vb, <8 x i1> %m, i32 %evl)
67 define <8 x half> @vfsgnj_vv_v8f16_unmasked(<8 x half> %va, <8 x half> %vb, i32 zeroext %evl) {
68 ; CHECK-LABEL: vfsgnj_vv_v8f16_unmasked:
70 ; CHECK-NEXT: vsetvli zero, a0, e16, m1, ta, ma
71 ; CHECK-NEXT: vfsgnj.vv v8, v8, v9
73 %head = insertelement <8 x i1> poison, i1 true, i32 0
74 %m = shufflevector <8 x i1> %head, <8 x i1> poison, <8 x i32> zeroinitializer
75 %v = call <8 x half> @llvm.vp.copysign.v8f16(<8 x half> %va, <8 x half> %vb, <8 x i1> %m, i32 %evl)
79 declare <16 x half> @llvm.vp.copysign.v16f16(<16 x half>, <16 x half>, <16 x i1>, i32)
81 define <16 x half> @vfsgnj_vv_v16f16(<16 x half> %va, <16 x half> %vb, <16 x i1> %m, i32 zeroext %evl) {
82 ; CHECK-LABEL: vfsgnj_vv_v16f16:
84 ; CHECK-NEXT: vsetvli zero, a0, e16, m2, ta, ma
85 ; CHECK-NEXT: vfsgnj.vv v8, v8, v10, v0.t
87 %v = call <16 x half> @llvm.vp.copysign.v16f16(<16 x half> %va, <16 x half> %vb, <16 x i1> %m, i32 %evl)
91 define <16 x half> @vfsgnj_vv_v16f16_unmasked(<16 x half> %va, <16 x half> %vb, i32 zeroext %evl) {
92 ; CHECK-LABEL: vfsgnj_vv_v16f16_unmasked:
94 ; CHECK-NEXT: vsetvli zero, a0, e16, m2, ta, ma
95 ; CHECK-NEXT: vfsgnj.vv v8, v8, v10
97 %head = insertelement <16 x i1> poison, i1 true, i32 0
98 %m = shufflevector <16 x i1> %head, <16 x i1> poison, <16 x i32> zeroinitializer
99 %v = call <16 x half> @llvm.vp.copysign.v16f16(<16 x half> %va, <16 x half> %vb, <16 x i1> %m, i32 %evl)
103 declare <2 x float> @llvm.vp.copysign.v2f32(<2 x float>, <2 x float>, <2 x i1>, i32)
105 define <2 x float> @vfsgnj_vv_v2f32(<2 x float> %va, <2 x float> %vb, <2 x i1> %m, i32 zeroext %evl) {
106 ; CHECK-LABEL: vfsgnj_vv_v2f32:
108 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
109 ; CHECK-NEXT: vfsgnj.vv v8, v8, v9, v0.t
111 %v = call <2 x float> @llvm.vp.copysign.v2f32(<2 x float> %va, <2 x float> %vb, <2 x i1> %m, i32 %evl)
115 define <2 x float> @vfsgnj_vv_v2f32_unmasked(<2 x float> %va, <2 x float> %vb, i32 zeroext %evl) {
116 ; CHECK-LABEL: vfsgnj_vv_v2f32_unmasked:
118 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
119 ; CHECK-NEXT: vfsgnj.vv v8, v8, v9
121 %head = insertelement <2 x i1> poison, i1 true, i32 0
122 %m = shufflevector <2 x i1> %head, <2 x i1> poison, <2 x i32> zeroinitializer
123 %v = call <2 x float> @llvm.vp.copysign.v2f32(<2 x float> %va, <2 x float> %vb, <2 x i1> %m, i32 %evl)
127 declare <4 x float> @llvm.vp.copysign.v4f32(<4 x float>, <4 x float>, <4 x i1>, i32)
129 define <4 x float> @vfsgnj_vv_v4f32(<4 x float> %va, <4 x float> %vb, <4 x i1> %m, i32 zeroext %evl) {
130 ; CHECK-LABEL: vfsgnj_vv_v4f32:
132 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
133 ; CHECK-NEXT: vfsgnj.vv v8, v8, v9, v0.t
135 %v = call <4 x float> @llvm.vp.copysign.v4f32(<4 x float> %va, <4 x float> %vb, <4 x i1> %m, i32 %evl)
139 define <4 x float> @vfsgnj_vv_v4f32_unmasked(<4 x float> %va, <4 x float> %vb, i32 zeroext %evl) {
140 ; CHECK-LABEL: vfsgnj_vv_v4f32_unmasked:
142 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
143 ; CHECK-NEXT: vfsgnj.vv v8, v8, v9
145 %head = insertelement <4 x i1> poison, i1 true, i32 0
146 %m = shufflevector <4 x i1> %head, <4 x i1> poison, <4 x i32> zeroinitializer
147 %v = call <4 x float> @llvm.vp.copysign.v4f32(<4 x float> %va, <4 x float> %vb, <4 x i1> %m, i32 %evl)
151 declare <8 x float> @llvm.vp.copysign.v8f32(<8 x float>, <8 x float>, <8 x i1>, i32)
153 define <8 x float> @vfsgnj_vv_v8f32(<8 x float> %va, <8 x float> %vb, <8 x i1> %m, i32 zeroext %evl) {
154 ; CHECK-LABEL: vfsgnj_vv_v8f32:
156 ; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma
157 ; CHECK-NEXT: vfsgnj.vv v8, v8, v10, v0.t
159 %v = call <8 x float> @llvm.vp.copysign.v8f32(<8 x float> %va, <8 x float> %vb, <8 x i1> %m, i32 %evl)
163 define <8 x float> @vfsgnj_vv_v8f32_unmasked(<8 x float> %va, <8 x float> %vb, i32 zeroext %evl) {
164 ; CHECK-LABEL: vfsgnj_vv_v8f32_unmasked:
166 ; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma
167 ; CHECK-NEXT: vfsgnj.vv v8, v8, v10
169 %head = insertelement <8 x i1> poison, i1 true, i32 0
170 %m = shufflevector <8 x i1> %head, <8 x i1> poison, <8 x i32> zeroinitializer
171 %v = call <8 x float> @llvm.vp.copysign.v8f32(<8 x float> %va, <8 x float> %vb, <8 x i1> %m, i32 %evl)
175 declare <16 x float> @llvm.vp.copysign.v16f32(<16 x float>, <16 x float>, <16 x i1>, i32)
177 define <16 x float> @vfsgnj_vv_v16f32(<16 x float> %va, <16 x float> %vb, <16 x i1> %m, i32 zeroext %evl) {
178 ; CHECK-LABEL: vfsgnj_vv_v16f32:
180 ; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma
181 ; CHECK-NEXT: vfsgnj.vv v8, v8, v12, v0.t
183 %v = call <16 x float> @llvm.vp.copysign.v16f32(<16 x float> %va, <16 x float> %vb, <16 x i1> %m, i32 %evl)
187 define <16 x float> @vfsgnj_vv_v16f32_unmasked(<16 x float> %va, <16 x float> %vb, i32 zeroext %evl) {
188 ; CHECK-LABEL: vfsgnj_vv_v16f32_unmasked:
190 ; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma
191 ; CHECK-NEXT: vfsgnj.vv v8, v8, v12
193 %head = insertelement <16 x i1> poison, i1 true, i32 0
194 %m = shufflevector <16 x i1> %head, <16 x i1> poison, <16 x i32> zeroinitializer
195 %v = call <16 x float> @llvm.vp.copysign.v16f32(<16 x float> %va, <16 x float> %vb, <16 x i1> %m, i32 %evl)
199 declare <2 x double> @llvm.vp.copysign.v2f64(<2 x double>, <2 x double>, <2 x i1>, i32)
201 define <2 x double> @vfsgnj_vv_v2f64(<2 x double> %va, <2 x double> %vb, <2 x i1> %m, i32 zeroext %evl) {
202 ; CHECK-LABEL: vfsgnj_vv_v2f64:
204 ; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma
205 ; CHECK-NEXT: vfsgnj.vv v8, v8, v9, v0.t
207 %v = call <2 x double> @llvm.vp.copysign.v2f64(<2 x double> %va, <2 x double> %vb, <2 x i1> %m, i32 %evl)
211 define <2 x double> @vfsgnj_vv_v2f64_unmasked(<2 x double> %va, <2 x double> %vb, i32 zeroext %evl) {
212 ; CHECK-LABEL: vfsgnj_vv_v2f64_unmasked:
214 ; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma
215 ; CHECK-NEXT: vfsgnj.vv v8, v8, v9
217 %head = insertelement <2 x i1> poison, i1 true, i32 0
218 %m = shufflevector <2 x i1> %head, <2 x i1> poison, <2 x i32> zeroinitializer
219 %v = call <2 x double> @llvm.vp.copysign.v2f64(<2 x double> %va, <2 x double> %vb, <2 x i1> %m, i32 %evl)
223 declare <4 x double> @llvm.vp.copysign.v4f64(<4 x double>, <4 x double>, <4 x i1>, i32)
225 define <4 x double> @vfsgnj_vv_v4f64(<4 x double> %va, <4 x double> %vb, <4 x i1> %m, i32 zeroext %evl) {
226 ; CHECK-LABEL: vfsgnj_vv_v4f64:
228 ; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma
229 ; CHECK-NEXT: vfsgnj.vv v8, v8, v10, v0.t
231 %v = call <4 x double> @llvm.vp.copysign.v4f64(<4 x double> %va, <4 x double> %vb, <4 x i1> %m, i32 %evl)
235 define <4 x double> @vfsgnj_vv_v4f64_unmasked(<4 x double> %va, <4 x double> %vb, i32 zeroext %evl) {
236 ; CHECK-LABEL: vfsgnj_vv_v4f64_unmasked:
238 ; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma
239 ; CHECK-NEXT: vfsgnj.vv v8, v8, v10
241 %head = insertelement <4 x i1> poison, i1 true, i32 0
242 %m = shufflevector <4 x i1> %head, <4 x i1> poison, <4 x i32> zeroinitializer
243 %v = call <4 x double> @llvm.vp.copysign.v4f64(<4 x double> %va, <4 x double> %vb, <4 x i1> %m, i32 %evl)
247 declare <8 x double> @llvm.vp.copysign.v8f64(<8 x double>, <8 x double>, <8 x i1>, i32)
249 define <8 x double> @vfsgnj_vv_v8f64(<8 x double> %va, <8 x double> %vb, <8 x i1> %m, i32 zeroext %evl) {
250 ; CHECK-LABEL: vfsgnj_vv_v8f64:
252 ; CHECK-NEXT: vsetvli zero, a0, e64, m4, ta, ma
253 ; CHECK-NEXT: vfsgnj.vv v8, v8, v12, v0.t
255 %v = call <8 x double> @llvm.vp.copysign.v8f64(<8 x double> %va, <8 x double> %vb, <8 x i1> %m, i32 %evl)
259 define <8 x double> @vfsgnj_vv_v8f64_unmasked(<8 x double> %va, <8 x double> %vb, i32 zeroext %evl) {
260 ; CHECK-LABEL: vfsgnj_vv_v8f64_unmasked:
262 ; CHECK-NEXT: vsetvli zero, a0, e64, m4, ta, ma
263 ; CHECK-NEXT: vfsgnj.vv v8, v8, v12
265 %head = insertelement <8 x i1> poison, i1 true, i32 0
266 %m = shufflevector <8 x i1> %head, <8 x i1> poison, <8 x i32> zeroinitializer
267 %v = call <8 x double> @llvm.vp.copysign.v8f64(<8 x double> %va, <8 x double> %vb, <8 x i1> %m, i32 %evl)
271 declare <15 x double> @llvm.vp.copysign.v15f64(<15 x double>, <15 x double>, <15 x i1>, i32)
273 define <15 x double> @vfsgnj_vv_v15f64(<15 x double> %va, <15 x double> %vb, <15 x i1> %m, i32 zeroext %evl) {
274 ; CHECK-LABEL: vfsgnj_vv_v15f64:
276 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
277 ; CHECK-NEXT: vfsgnj.vv v8, v8, v16, v0.t
279 %v = call <15 x double> @llvm.vp.copysign.v15f64(<15 x double> %va, <15 x double> %vb, <15 x i1> %m, i32 %evl)
283 define <15 x double> @vfsgnj_vv_v15f64_unmasked(<15 x double> %va, <15 x double> %vb, i32 zeroext %evl) {
284 ; CHECK-LABEL: vfsgnj_vv_v15f64_unmasked:
286 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
287 ; CHECK-NEXT: vfsgnj.vv v8, v8, v16
289 %head = insertelement <15 x i1> poison, i1 true, i32 0
290 %m = shufflevector <15 x i1> %head, <15 x i1> poison, <15 x i32> zeroinitializer
291 %v = call <15 x double> @llvm.vp.copysign.v15f64(<15 x double> %va, <15 x double> %vb, <15 x i1> %m, i32 %evl)
295 declare <16 x double> @llvm.vp.copysign.v16f64(<16 x double>, <16 x double>, <16 x i1>, i32)
297 define <16 x double> @vfsgnj_vv_v16f64(<16 x double> %va, <16 x double> %vb, <16 x i1> %m, i32 zeroext %evl) {
298 ; CHECK-LABEL: vfsgnj_vv_v16f64:
300 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
301 ; CHECK-NEXT: vfsgnj.vv v8, v8, v16, v0.t
303 %v = call <16 x double> @llvm.vp.copysign.v16f64(<16 x double> %va, <16 x double> %vb, <16 x i1> %m, i32 %evl)
307 define <16 x double> @vfsgnj_vv_v16f64_unmasked(<16 x double> %va, <16 x double> %vb, i32 zeroext %evl) {
308 ; CHECK-LABEL: vfsgnj_vv_v16f64_unmasked:
310 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
311 ; CHECK-NEXT: vfsgnj.vv v8, v8, v16
313 %head = insertelement <16 x i1> poison, i1 true, i32 0
314 %m = shufflevector <16 x i1> %head, <16 x i1> poison, <16 x i32> zeroinitializer
315 %v = call <16 x double> @llvm.vp.copysign.v16f64(<16 x double> %va, <16 x double> %vb, <16 x i1> %m, i32 %evl)
319 declare <32 x double> @llvm.vp.copysign.v32f64(<32 x double>, <32 x double>, <32 x i1>, i32)
321 define <32 x double> @vfsgnj_vv_v32f64(<32 x double> %va, <32 x double> %vb, <32 x i1> %m, i32 zeroext %evl) {
322 ; CHECK-LABEL: vfsgnj_vv_v32f64:
324 ; CHECK-NEXT: addi sp, sp, -16
325 ; CHECK-NEXT: .cfi_def_cfa_offset 16
326 ; CHECK-NEXT: csrr a1, vlenb
327 ; CHECK-NEXT: slli a1, a1, 3
328 ; CHECK-NEXT: sub sp, sp, a1
329 ; CHECK-NEXT: .cfi_escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x10, 0x22, 0x11, 0x08, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # sp + 16 + 8 * vlenb
330 ; CHECK-NEXT: addi a1, a0, 128
331 ; CHECK-NEXT: vsetivli zero, 16, e64, m8, ta, ma
332 ; CHECK-NEXT: vle64.v v24, (a1)
333 ; CHECK-NEXT: addi a1, sp, 16
334 ; CHECK-NEXT: vs8r.v v24, (a1) # Unknown-size Folded Spill
335 ; CHECK-NEXT: vsetivli zero, 2, e8, mf4, ta, ma
336 ; CHECK-NEXT: vslidedown.vi v1, v0, 2
337 ; CHECK-NEXT: vsetivli zero, 16, e64, m8, ta, ma
338 ; CHECK-NEXT: vle64.v v24, (a0)
339 ; CHECK-NEXT: li a1, 16
340 ; CHECK-NEXT: mv a0, a2
341 ; CHECK-NEXT: bltu a2, a1, .LBB26_2
342 ; CHECK-NEXT: # %bb.1:
343 ; CHECK-NEXT: li a0, 16
344 ; CHECK-NEXT: .LBB26_2:
345 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
346 ; CHECK-NEXT: vfsgnj.vv v8, v8, v24, v0.t
347 ; CHECK-NEXT: addi a0, a2, -16
348 ; CHECK-NEXT: sltu a1, a2, a0
349 ; CHECK-NEXT: addi a1, a1, -1
350 ; CHECK-NEXT: and a0, a1, a0
351 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
352 ; CHECK-NEXT: vmv1r.v v0, v1
353 ; CHECK-NEXT: addi a0, sp, 16
354 ; CHECK-NEXT: vl8r.v v24, (a0) # Unknown-size Folded Reload
355 ; CHECK-NEXT: vfsgnj.vv v16, v16, v24, v0.t
356 ; CHECK-NEXT: csrr a0, vlenb
357 ; CHECK-NEXT: slli a0, a0, 3
358 ; CHECK-NEXT: add sp, sp, a0
359 ; CHECK-NEXT: addi sp, sp, 16
361 %v = call <32 x double> @llvm.vp.copysign.v32f64(<32 x double> %va, <32 x double> %vb, <32 x i1> %m, i32 %evl)
365 define <32 x double> @vfsgnj_vv_v32f64_unmasked(<32 x double> %va, <32 x double> %vb, i32 zeroext %evl) {
366 ; CHECK-LABEL: vfsgnj_vv_v32f64_unmasked:
368 ; CHECK-NEXT: addi a1, a0, 128
369 ; CHECK-NEXT: vsetivli zero, 16, e64, m8, ta, ma
370 ; CHECK-NEXT: vle64.v v24, (a1)
371 ; CHECK-NEXT: vle64.v v0, (a0)
372 ; CHECK-NEXT: li a1, 16
373 ; CHECK-NEXT: mv a0, a2
374 ; CHECK-NEXT: bltu a2, a1, .LBB27_2
375 ; CHECK-NEXT: # %bb.1:
376 ; CHECK-NEXT: li a0, 16
377 ; CHECK-NEXT: .LBB27_2:
378 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
379 ; CHECK-NEXT: vfsgnj.vv v8, v8, v0
380 ; CHECK-NEXT: addi a0, a2, -16
381 ; CHECK-NEXT: sltu a1, a2, a0
382 ; CHECK-NEXT: addi a1, a1, -1
383 ; CHECK-NEXT: and a0, a1, a0
384 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
385 ; CHECK-NEXT: vfsgnj.vv v16, v16, v24
387 %head = insertelement <32 x i1> poison, i1 true, i32 0
388 %m = shufflevector <32 x i1> %head, <32 x i1> poison, <32 x i32> zeroinitializer
389 %v = call <32 x double> @llvm.vp.copysign.v32f64(<32 x double> %va, <32 x double> %vb, <32 x i1> %m, i32 %evl)