1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s --mattr=+complxnum,+neon,+fullfp16 -o - | FileCheck %s
3 ; RUN: llc < %s --mattr=+complxnum,+neon,+fullfp16,+sve -o - | FileCheck %s
5 target triple = "aarch64"
7 ; Expected to not transform
8 define <2 x half> @complex_add_v2f16(<2 x half> %a, <2 x half> %b) {
9 ; CHECK-LABEL: complex_add_v2f16:
10 ; CHECK: // %bb.0: // %entry
11 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1
12 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
13 ; CHECK-NEXT: mov h2, v0.h[1]
14 ; CHECK-NEXT: mov h3, v1.h[1]
15 ; CHECK-NEXT: fsub h1, h1, h2
16 ; CHECK-NEXT: fadd h0, h3, h0
17 ; CHECK-NEXT: mov v1.h[1], v0.h[0]
18 ; CHECK-NEXT: fmov d0, d1
21 %a.real = shufflevector <2 x half> %a, <2 x half> zeroinitializer, <1 x i32> <i32 0>
22 %a.imag = shufflevector <2 x half> %a, <2 x half> zeroinitializer, <1 x i32> <i32 1>
23 %b.real = shufflevector <2 x half> %b, <2 x half> zeroinitializer, <1 x i32> <i32 0>
24 %b.imag = shufflevector <2 x half> %b, <2 x half> zeroinitializer, <1 x i32> <i32 1>
25 %0 = fsub fast <1 x half> %b.real, %a.imag
26 %1 = fadd fast <1 x half> %b.imag, %a.real
27 %interleaved.vec = shufflevector <1 x half> %0, <1 x half> %1, <2 x i32> <i32 0, i32 1>
28 ret <2 x half> %interleaved.vec
31 ; Expected to transform
32 define <4 x half> @complex_add_v4f16(<4 x half> %a, <4 x half> %b) {
33 ; CHECK-LABEL: complex_add_v4f16:
34 ; CHECK: // %bb.0: // %entry
35 ; CHECK-NEXT: fcadd v0.4h, v1.4h, v0.4h, #90
38 %a.real = shufflevector <4 x half> %a, <4 x half> zeroinitializer, <2 x i32> <i32 0, i32 2>
39 %a.imag = shufflevector <4 x half> %a, <4 x half> zeroinitializer, <2 x i32> <i32 1, i32 3>
40 %b.real = shufflevector <4 x half> %b, <4 x half> zeroinitializer, <2 x i32> <i32 0, i32 2>
41 %b.imag = shufflevector <4 x half> %b, <4 x half> zeroinitializer, <2 x i32> <i32 1, i32 3>
42 %0 = fsub fast <2 x half> %b.real, %a.imag
43 %1 = fadd fast <2 x half> %b.imag, %a.real
44 %interleaved.vec = shufflevector <2 x half> %0, <2 x half> %1, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
45 ret <4 x half> %interleaved.vec
48 ; Expected to transform
49 define <8 x half> @complex_add_v8f16(<8 x half> %a, <8 x half> %b) {
50 ; CHECK-LABEL: complex_add_v8f16:
51 ; CHECK: // %bb.0: // %entry
52 ; CHECK-NEXT: fcadd v0.8h, v1.8h, v0.8h, #90
55 %a.real = shufflevector <8 x half> %a, <8 x half> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
56 %a.imag = shufflevector <8 x half> %a, <8 x half> zeroinitializer, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
57 %b.real = shufflevector <8 x half> %b, <8 x half> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
58 %b.imag = shufflevector <8 x half> %b, <8 x half> zeroinitializer, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
59 %0 = fsub fast <4 x half> %b.real, %a.imag
60 %1 = fadd fast <4 x half> %b.imag, %a.real
61 %interleaved.vec = shufflevector <4 x half> %0, <4 x half> %1, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
62 ret <8 x half> %interleaved.vec
65 ; Expected to transform
66 define <16 x half> @complex_add_v16f16(<16 x half> %a, <16 x half> %b) {
67 ; CHECK-LABEL: complex_add_v16f16:
68 ; CHECK: // %bb.0: // %entry
69 ; CHECK-NEXT: fcadd v1.8h, v3.8h, v1.8h, #90
70 ; CHECK-NEXT: fcadd v0.8h, v2.8h, v0.8h, #90
73 %a.real = shufflevector <16 x half> %a, <16 x half> zeroinitializer, <8 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14>
74 %a.imag = shufflevector <16 x half> %a, <16 x half> zeroinitializer, <8 x i32> <i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15>
75 %b.real = shufflevector <16 x half> %b, <16 x half> zeroinitializer, <8 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14>
76 %b.imag = shufflevector <16 x half> %b, <16 x half> zeroinitializer, <8 x i32> <i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15>
77 %0 = fsub fast <8 x half> %b.real, %a.imag
78 %1 = fadd fast <8 x half> %b.imag, %a.real
79 %interleaved.vec = shufflevector <8 x half> %0, <8 x half> %1, <16 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11, i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
80 ret <16 x half> %interleaved.vec
83 ; Expected to transform
84 define <32 x half> @complex_add_v32f16(<32 x half> %a, <32 x half> %b) {
85 ; CHECK-LABEL: complex_add_v32f16:
86 ; CHECK: // %bb.0: // %entry
87 ; CHECK-NEXT: fcadd v2.8h, v6.8h, v2.8h, #90
88 ; CHECK-NEXT: fcadd v0.8h, v4.8h, v0.8h, #90
89 ; CHECK-NEXT: fcadd v1.8h, v5.8h, v1.8h, #90
90 ; CHECK-NEXT: fcadd v3.8h, v7.8h, v3.8h, #90
93 %a.real = shufflevector <32 x half> %a, <32 x half> zeroinitializer, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14, i32 16, i32 18, i32 20, i32 22, i32 24, i32 26, i32 28, i32 30>
94 %a.imag = shufflevector <32 x half> %a, <32 x half> zeroinitializer, <16 x i32> <i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15, i32 17, i32 19, i32 21, i32 23, i32 25, i32 27, i32 29, i32 31>
95 %b.real = shufflevector <32 x half> %b, <32 x half> zeroinitializer, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14, i32 16, i32 18, i32 20, i32 22, i32 24, i32 26, i32 28, i32 30>
96 %b.imag = shufflevector <32 x half> %b, <32 x half> zeroinitializer, <16 x i32> <i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15, i32 17, i32 19, i32 21, i32 23, i32 25, i32 27, i32 29, i32 31>
97 %0 = fsub fast <16 x half> %b.real, %a.imag
98 %1 = fadd fast <16 x half> %b.imag, %a.real
99 %interleaved.vec = shufflevector <16 x half> %0, <16 x half> %1, <32 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23, i32 8, i32 24, i32 9, i32 25, i32 10, i32 26, i32 11, i32 27, i32 12, i32 28, i32 13, i32 29, i32 14, i32 30, i32 15, i32 31>
100 ret <32 x half> %interleaved.vec
103 ; Expected to transform
104 define <4 x half> @complex_add_v4f16_with_intrinsic(<4 x half> %a, <4 x half> %b) {
105 ; CHECK-LABEL: complex_add_v4f16_with_intrinsic:
106 ; CHECK: // %bb.0: // %entry
107 ; CHECK-NEXT: fcadd v0.4h, v1.4h, v0.4h, #90
110 %a.deinterleaved = tail call { <2 x half>, <2 x half> } @llvm.experimental.vector.deinterleave2.v4f16(<4 x half> %a)
111 %a.real = extractvalue { <2 x half>, <2 x half> } %a.deinterleaved, 0
112 %a.imag = extractvalue { <2 x half>, <2 x half> } %a.deinterleaved, 1
113 %b.deinterleaved = tail call { <2 x half>, <2 x half> } @llvm.experimental.vector.deinterleave2.v4f16(<4 x half> %b)
114 %b.real = extractvalue { <2 x half>, <2 x half> } %b.deinterleaved, 0
115 %b.imag = extractvalue { <2 x half>, <2 x half> } %b.deinterleaved, 1
116 %0 = fsub fast <2 x half> %b.real, %a.imag
117 %1 = fadd fast <2 x half> %b.imag, %a.real
118 %interleaved.vec = tail call <4 x half> @llvm.experimental.vector.interleave2.v4f16(<2 x half> %0, <2 x half> %1)
119 ret <4 x half> %interleaved.vec
122 ; Expected to transform
123 define <8 x half> @complex_add_v8f16_with_intrinsic(<8 x half> %a, <8 x half> %b) {
124 ; CHECK-LABEL: complex_add_v8f16_with_intrinsic:
125 ; CHECK: // %bb.0: // %entry
126 ; CHECK-NEXT: fcadd v0.8h, v1.8h, v0.8h, #90
129 %a.deinterleaved = tail call { <4 x half>, <4 x half> } @llvm.experimental.vector.deinterleave2.v8f16(<8 x half> %a)
130 %a.real = extractvalue { <4 x half>, <4 x half> } %a.deinterleaved, 0
131 %a.imag = extractvalue { <4 x half>, <4 x half> } %a.deinterleaved, 1
132 %b.deinterleaved = tail call { <4 x half>, <4 x half> } @llvm.experimental.vector.deinterleave2.v8f16(<8 x half> %b)
133 %b.real = extractvalue { <4 x half>, <4 x half> } %b.deinterleaved, 0
134 %b.imag = extractvalue { <4 x half>, <4 x half> } %b.deinterleaved, 1
135 %0 = fsub fast <4 x half> %b.real, %a.imag
136 %1 = fadd fast <4 x half> %b.imag, %a.real
137 %interleaved.vec = tail call <8 x half> @llvm.experimental.vector.interleave2.v8f16(<4 x half> %0, <4 x half> %1)
138 ret <8 x half> %interleaved.vec
141 ; Expected to transform
142 define <16 x half> @complex_add_v16f16_with_intrinsic(<16 x half> %a, <16 x half> %b) {
143 ; CHECK-LABEL: complex_add_v16f16_with_intrinsic:
144 ; CHECK: // %bb.0: // %entry
145 ; CHECK-NEXT: fcadd v1.8h, v3.8h, v1.8h, #90
146 ; CHECK-NEXT: fcadd v0.8h, v2.8h, v0.8h, #90
149 %a.deinterleaved = tail call { <8 x half>, <8 x half> } @llvm.experimental.vector.deinterleave2.v16f16(<16 x half> %a)
150 %a.real = extractvalue { <8 x half>, <8 x half> } %a.deinterleaved, 0
151 %a.imag = extractvalue { <8 x half>, <8 x half> } %a.deinterleaved, 1
152 %b.deinterleaved = tail call { <8 x half>, <8 x half> } @llvm.experimental.vector.deinterleave2.v16f16(<16 x half> %b)
153 %b.real = extractvalue { <8 x half>, <8 x half> } %b.deinterleaved, 0
154 %b.imag = extractvalue { <8 x half>, <8 x half> } %b.deinterleaved, 1
155 %0 = fsub fast <8 x half> %b.real, %a.imag
156 %1 = fadd fast <8 x half> %b.imag, %a.real
157 %interleaved.vec = tail call <16 x half> @llvm.experimental.vector.interleave2.v16f16(<8 x half> %0, <8 x half> %1)
158 ret <16 x half> %interleaved.vec
161 declare { <2 x half>, <2 x half> } @llvm.experimental.vector.deinterleave2.v4f16(<4 x half>)
162 declare <4 x half> @llvm.experimental.vector.interleave2.v4f16(<2 x half>, <2 x half>)
164 declare { <4 x half>, <4 x half> } @llvm.experimental.vector.deinterleave2.v8f16(<8 x half>)
165 declare <8 x half> @llvm.experimental.vector.interleave2.v8f16(<4 x half>, <4 x half>)
167 declare { <8 x half>, <8 x half> } @llvm.experimental.vector.deinterleave2.v16f16(<16 x half>)
168 declare <16 x half> @llvm.experimental.vector.interleave2.v16f16(<8 x half>, <8 x half>)