1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple aarch64-apple-darwin | FileCheck --check-prefixes=CHECK,NOFP16 %s
3 ; RUN: llc < %s -mtriple aarch64-apple-darwin -mattr=+v8.2a,+fullfp16 | FileCheck --check-prefixes=CHECK,FP16 %s
5 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
10 define <1 x float> @test_copysign_v1f32_v1f32(<1 x float> %a, <1 x float> %b) #0 {
11 ; CHECK-LABEL: test_copysign_v1f32_v1f32:
13 ; CHECK-NEXT: mvni.2s v2, #128, lsl #24
14 ; CHECK-NEXT: bif.8b v0, v1, v2
16 %r = call <1 x float> @llvm.copysign.v1f32(<1 x float> %a, <1 x float> %b)
20 ; WidenVecRes mismatched
21 define <1 x float> @test_copysign_v1f32_v1f64(<1 x float> %a, <1 x double> %b) #0 {
22 ; CHECK-LABEL: test_copysign_v1f32_v1f64:
24 ; CHECK-NEXT: ; kill: def $d1 killed $d1 def $q1
25 ; CHECK-NEXT: mvni.2s v2, #128, lsl #24
26 ; CHECK-NEXT: fcvtn v1.2s, v1.2d
27 ; CHECK-NEXT: bif.8b v0, v1, v2
29 %tmp0 = fptrunc <1 x double> %b to <1 x float>
30 %r = call <1 x float> @llvm.copysign.v1f32(<1 x float> %a, <1 x float> %tmp0)
34 declare <1 x float> @llvm.copysign.v1f32(<1 x float> %a, <1 x float> %b) #0
39 define <1 x double> @test_copysign_v1f64_v1f32(<1 x double> %a, <1 x float> %b) #0 {
40 ; CHECK-LABEL: test_copysign_v1f64_v1f32:
42 ; CHECK-NEXT: movi.2d v2, #0xffffffffffffffff
43 ; CHECK-NEXT: fcvtl v1.2d, v1.2s
44 ; CHECK-NEXT: ; kill: def $d0 killed $d0 def $q0
45 ; CHECK-NEXT: fneg.2d v2, v2
46 ; CHECK-NEXT: bif.16b v0, v1, v2
47 ; CHECK-NEXT: ; kill: def $d0 killed $d0 killed $q0
49 %tmp0 = fpext <1 x float> %b to <1 x double>
50 %r = call <1 x double> @llvm.copysign.v1f64(<1 x double> %a, <1 x double> %tmp0)
54 define <1 x double> @test_copysign_v1f64_v1f64(<1 x double> %a, <1 x double> %b) #0 {
55 ; CHECK-LABEL: test_copysign_v1f64_v1f64:
57 ; CHECK-NEXT: movi.2d v2, #0xffffffffffffffff
58 ; CHECK-NEXT: ; kill: def $d0 killed $d0 def $q0
59 ; CHECK-NEXT: ; kill: def $d1 killed $d1 def $q1
60 ; CHECK-NEXT: fneg.2d v2, v2
61 ; CHECK-NEXT: bif.16b v0, v1, v2
62 ; CHECK-NEXT: ; kill: def $d0 killed $d0 killed $q0
64 %r = call <1 x double> @llvm.copysign.v1f64(<1 x double> %a, <1 x double> %b)
68 declare <1 x double> @llvm.copysign.v1f64(<1 x double> %a, <1 x double> %b) #0
72 define <2 x float> @test_copysign_v2f32_v2f32(<2 x float> %a, <2 x float> %b) #0 {
73 ; CHECK-LABEL: test_copysign_v2f32_v2f32:
75 ; CHECK-NEXT: mvni.2s v2, #128, lsl #24
76 ; CHECK-NEXT: bif.8b v0, v1, v2
78 %r = call <2 x float> @llvm.copysign.v2f32(<2 x float> %a, <2 x float> %b)
82 define <2 x float> @test_copysign_v2f32_v2f64(<2 x float> %a, <2 x double> %b) #0 {
83 ; CHECK-LABEL: test_copysign_v2f32_v2f64:
85 ; CHECK-NEXT: fcvtn v1.2s, v1.2d
86 ; CHECK-NEXT: mvni.2s v2, #128, lsl #24
87 ; CHECK-NEXT: bif.8b v0, v1, v2
89 %tmp0 = fptrunc <2 x double> %b to <2 x float>
90 %r = call <2 x float> @llvm.copysign.v2f32(<2 x float> %a, <2 x float> %tmp0)
94 declare <2 x float> @llvm.copysign.v2f32(<2 x float> %a, <2 x float> %b) #0
98 define <4 x float> @test_copysign_v4f32_v4f32(<4 x float> %a, <4 x float> %b) #0 {
99 ; CHECK-LABEL: test_copysign_v4f32_v4f32:
101 ; CHECK-NEXT: mvni.4s v2, #128, lsl #24
102 ; CHECK-NEXT: bif.16b v0, v1, v2
104 %r = call <4 x float> @llvm.copysign.v4f32(<4 x float> %a, <4 x float> %b)
109 define <4 x float> @test_copysign_v4f32_v4f64(<4 x float> %a, <4 x double> %b) #0 {
110 ; CHECK-LABEL: test_copysign_v4f32_v4f64:
112 ; CHECK-NEXT: fcvtn v1.2s, v1.2d
113 ; CHECK-NEXT: fcvtn2 v1.4s, v2.2d
114 ; CHECK-NEXT: mvni.4s v2, #128, lsl #24
115 ; CHECK-NEXT: bif.16b v0, v1, v2
117 %tmp0 = fptrunc <4 x double> %b to <4 x float>
118 %r = call <4 x float> @llvm.copysign.v4f32(<4 x float> %a, <4 x float> %tmp0)
122 declare <4 x float> @llvm.copysign.v4f32(<4 x float> %a, <4 x float> %b) #0
126 define <2 x double> @test_copysign_v2f64_v232(<2 x double> %a, <2 x float> %b) #0 {
127 ; CHECK-LABEL: test_copysign_v2f64_v232:
129 ; CHECK-NEXT: movi.2d v2, #0xffffffffffffffff
130 ; CHECK-NEXT: fcvtl v1.2d, v1.2s
131 ; CHECK-NEXT: fneg.2d v2, v2
132 ; CHECK-NEXT: bif.16b v0, v1, v2
134 %tmp0 = fpext <2 x float> %b to <2 x double>
135 %r = call <2 x double> @llvm.copysign.v2f64(<2 x double> %a, <2 x double> %tmp0)
139 define <2 x double> @test_copysign_v2f64_v2f64(<2 x double> %a, <2 x double> %b) #0 {
140 ; CHECK-LABEL: test_copysign_v2f64_v2f64:
142 ; CHECK-NEXT: movi.2d v2, #0xffffffffffffffff
143 ; CHECK-NEXT: fneg.2d v2, v2
144 ; CHECK-NEXT: bif.16b v0, v1, v2
146 %r = call <2 x double> @llvm.copysign.v2f64(<2 x double> %a, <2 x double> %b)
150 declare <2 x double> @llvm.copysign.v2f64(<2 x double> %a, <2 x double> %b) #0
154 ; SplitVecRes mismatched
155 define <4 x double> @test_copysign_v4f64_v4f32(<4 x double> %a, <4 x float> %b) #0 {
156 ; CHECK-LABEL: test_copysign_v4f64_v4f32:
158 ; CHECK-NEXT: movi.2d v3, #0xffffffffffffffff
159 ; CHECK-NEXT: fcvtl v4.2d, v2.2s
160 ; CHECK-NEXT: fcvtl2 v2.2d, v2.4s
161 ; CHECK-NEXT: fneg.2d v3, v3
162 ; CHECK-NEXT: bif.16b v1, v2, v3
163 ; CHECK-NEXT: bif.16b v0, v4, v3
165 %tmp0 = fpext <4 x float> %b to <4 x double>
166 %r = call <4 x double> @llvm.copysign.v4f64(<4 x double> %a, <4 x double> %tmp0)
171 define <4 x double> @test_copysign_v4f64_v4f64(<4 x double> %a, <4 x double> %b) #0 {
172 ; CHECK-LABEL: test_copysign_v4f64_v4f64:
174 ; CHECK-NEXT: movi.2d v4, #0xffffffffffffffff
175 ; CHECK-NEXT: fneg.2d v4, v4
176 ; CHECK-NEXT: bif.16b v0, v2, v4
177 ; CHECK-NEXT: bif.16b v1, v3, v4
179 %r = call <4 x double> @llvm.copysign.v4f64(<4 x double> %a, <4 x double> %b)
183 declare <4 x double> @llvm.copysign.v4f64(<4 x double> %a, <4 x double> %b) #0
187 define <4 x half> @test_copysign_v4f16_v4f16(<4 x half> %a, <4 x half> %b) #0 {
188 ; CHECK-LABEL: test_copysign_v4f16_v4f16:
190 ; CHECK-NEXT: mvni.4h v2, #128, lsl #8
191 ; CHECK-NEXT: bif.8b v0, v1, v2
193 %r = call <4 x half> @llvm.copysign.v4f16(<4 x half> %a, <4 x half> %b)
197 define <4 x half> @test_copysign_v4f16_v4f32(<4 x half> %a, <4 x float> %b) #0 {
198 ; CHECK-LABEL: test_copysign_v4f16_v4f32:
200 ; CHECK-NEXT: fcvtn v1.4h, v1.4s
201 ; CHECK-NEXT: mvni.4h v2, #128, lsl #8
202 ; CHECK-NEXT: bif.8b v0, v1, v2
204 %tmp0 = fptrunc <4 x float> %b to <4 x half>
205 %r = call <4 x half> @llvm.copysign.v4f16(<4 x half> %a, <4 x half> %tmp0)
209 define <4 x half> @test_copysign_v4f16_v4f64(<4 x half> %a, <4 x double> %b) #0 {
210 ; CHECK-LABEL: test_copysign_v4f16_v4f64:
212 ; CHECK-NEXT: fcvtxn v1.2s, v1.2d
213 ; CHECK-NEXT: fcvtxn2 v1.4s, v2.2d
214 ; CHECK-NEXT: mvni.4h v2, #128, lsl #8
215 ; CHECK-NEXT: fcvtn v1.4h, v1.4s
216 ; CHECK-NEXT: bif.8b v0, v1, v2
218 %tmp0 = fptrunc <4 x double> %b to <4 x half>
219 %r = call <4 x half> @llvm.copysign.v4f16(<4 x half> %a, <4 x half> %tmp0)
223 declare <4 x half> @llvm.copysign.v4f16(<4 x half> %a, <4 x half> %b) #0
227 define <8 x half> @test_copysign_v8f16_v8f16(<8 x half> %a, <8 x half> %b) #0 {
228 ; CHECK-LABEL: test_copysign_v8f16_v8f16:
230 ; CHECK-NEXT: mvni.8h v2, #128, lsl #8
231 ; CHECK-NEXT: bif.16b v0, v1, v2
233 %r = call <8 x half> @llvm.copysign.v8f16(<8 x half> %a, <8 x half> %b)
237 define <8 x half> @test_copysign_v8f16_v8f32(<8 x half> %a, <8 x float> %b) #0 {
238 ; CHECK-LABEL: test_copysign_v8f16_v8f32:
240 ; CHECK-NEXT: fcvtn v1.4h, v1.4s
241 ; CHECK-NEXT: fcvtn2 v1.8h, v2.4s
242 ; CHECK-NEXT: mvni.8h v2, #128, lsl #8
243 ; CHECK-NEXT: bif.16b v0, v1, v2
245 %tmp0 = fptrunc <8 x float> %b to <8 x half>
246 %r = call <8 x half> @llvm.copysign.v8f16(<8 x half> %a, <8 x half> %tmp0)
250 declare <8 x half> @llvm.copysign.v8f16(<8 x half> %a, <8 x half> %b) #0
254 define <4 x bfloat> @test_copysign_v4bf16_v4bf16(<4 x bfloat> %a, <4 x bfloat> %b) #0 {
255 ; CHECK-LABEL: test_copysign_v4bf16_v4bf16:
257 ; CHECK-NEXT: mvni.4h v2, #128, lsl #8
258 ; CHECK-NEXT: bif.8b v0, v1, v2
260 %r = call <4 x bfloat> @llvm.copysign.v4bf16(<4 x bfloat> %a, <4 x bfloat> %b)
264 define <4 x bfloat> @test_copysign_v4bf16_v4f32(<4 x bfloat> %a, <4 x float> %b) #0 {
265 ; CHECK-LABEL: test_copysign_v4bf16_v4f32:
267 ; CHECK-NEXT: movi.4s v2, #1
268 ; CHECK-NEXT: movi.4s v3, #127, msl #8
269 ; CHECK-NEXT: ushr.4s v4, v1, #16
270 ; CHECK-NEXT: and.16b v2, v4, v2
271 ; CHECK-NEXT: add.4s v3, v1, v3
272 ; CHECK-NEXT: fcmeq.4s v4, v1, v1
273 ; CHECK-NEXT: orr.4s v1, #64, lsl #16
274 ; CHECK-NEXT: add.4s v2, v2, v3
275 ; CHECK-NEXT: bit.16b v1, v2, v4
276 ; CHECK-NEXT: mvni.4h v2, #128, lsl #8
277 ; CHECK-NEXT: shrn.4h v1, v1, #16
278 ; CHECK-NEXT: bif.8b v0, v1, v2
280 %tmp0 = fptrunc <4 x float> %b to <4 x bfloat>
281 %r = call <4 x bfloat> @llvm.copysign.v4bf16(<4 x bfloat> %a, <4 x bfloat> %tmp0)
285 define <4 x bfloat> @test_copysign_v4bf16_v4f64(<4 x bfloat> %a, <4 x double> %b) #0 {
286 ; CHECK-LABEL: test_copysign_v4bf16_v4f64:
288 ; CHECK-NEXT: fcvtxn v1.2s, v1.2d
289 ; CHECK-NEXT: movi.4s v3, #127, msl #8
290 ; CHECK-NEXT: fcvtxn2 v1.4s, v2.2d
291 ; CHECK-NEXT: movi.4s v2, #1
292 ; CHECK-NEXT: ushr.4s v4, v1, #16
293 ; CHECK-NEXT: add.4s v3, v1, v3
294 ; CHECK-NEXT: and.16b v2, v4, v2
295 ; CHECK-NEXT: fcmeq.4s v4, v1, v1
296 ; CHECK-NEXT: orr.4s v1, #64, lsl #16
297 ; CHECK-NEXT: add.4s v2, v2, v3
298 ; CHECK-NEXT: bit.16b v1, v2, v4
299 ; CHECK-NEXT: mvni.4h v2, #128, lsl #8
300 ; CHECK-NEXT: shrn.4h v1, v1, #16
301 ; CHECK-NEXT: bif.8b v0, v1, v2
303 %tmp0 = fptrunc <4 x double> %b to <4 x bfloat>
304 %r = call <4 x bfloat> @llvm.copysign.v4bf16(<4 x bfloat> %a, <4 x bfloat> %tmp0)
308 declare <4 x bfloat> @llvm.copysign.v4bf16(<4 x bfloat> %a, <4 x bfloat> %b) #0
312 define <8 x bfloat> @test_copysign_v8bf16_v8bf16(<8 x bfloat> %a, <8 x bfloat> %b) #0 {
313 ; CHECK-LABEL: test_copysign_v8bf16_v8bf16:
315 ; CHECK-NEXT: mvni.8h v2, #128, lsl #8
316 ; CHECK-NEXT: bif.16b v0, v1, v2
318 %r = call <8 x bfloat> @llvm.copysign.v8bf16(<8 x bfloat> %a, <8 x bfloat> %b)
322 define <8 x bfloat> @test_copysign_v8bf16_v8f32(<8 x bfloat> %a, <8 x float> %b) #0 {
323 ; CHECK-LABEL: test_copysign_v8bf16_v8f32:
325 ; CHECK-NEXT: movi.4s v3, #1
326 ; CHECK-NEXT: movi.4s v4, #127, msl #8
327 ; CHECK-NEXT: ushr.4s v5, v2, #16
328 ; CHECK-NEXT: ushr.4s v6, v1, #16
329 ; CHECK-NEXT: and.16b v5, v5, v3
330 ; CHECK-NEXT: add.4s v7, v2, v4
331 ; CHECK-NEXT: and.16b v3, v6, v3
332 ; CHECK-NEXT: add.4s v4, v1, v4
333 ; CHECK-NEXT: fcmeq.4s v6, v2, v2
334 ; CHECK-NEXT: orr.4s v2, #64, lsl #16
335 ; CHECK-NEXT: add.4s v5, v5, v7
336 ; CHECK-NEXT: fcmeq.4s v7, v1, v1
337 ; CHECK-NEXT: orr.4s v1, #64, lsl #16
338 ; CHECK-NEXT: add.4s v3, v3, v4
339 ; CHECK-NEXT: bit.16b v2, v5, v6
340 ; CHECK-NEXT: bit.16b v1, v3, v7
341 ; CHECK-NEXT: uzp2.8h v1, v1, v2
342 ; CHECK-NEXT: mvni.8h v2, #128, lsl #8
343 ; CHECK-NEXT: bif.16b v0, v1, v2
345 %tmp0 = fptrunc <8 x float> %b to <8 x bfloat>
346 %r = call <8 x bfloat> @llvm.copysign.v8bf16(<8 x bfloat> %a, <8 x bfloat> %tmp0)
350 declare <8 x bfloat> @llvm.copysign.v8bf16(<8 x bfloat> %a, <8 x bfloat> %b) #0
352 attributes #0 = { nounwind }
353 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: