1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mattr=+sve -force-streaming-compatible-sve < %s | FileCheck %s
4 target triple = "aarch64-unknown-linux-gnu"
6 define <2 x half> @select_v2f16(<2 x half> %op1, <2 x half> %op2, <2 x i1> %mask) {
7 ; CHECK-LABEL: select_v2f16:
9 ; CHECK-NEXT: sub sp, sp, #16
10 ; CHECK-NEXT: .cfi_def_cfa_offset 16
11 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
12 ; CHECK-NEXT: mov z3.s, z2.s[1]
13 ; CHECK-NEXT: fmov w8, s2
14 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
15 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
16 ; CHECK-NEXT: ptrue p0.h
17 ; CHECK-NEXT: strh w8, [sp, #8]
18 ; CHECK-NEXT: fmov w8, s3
19 ; CHECK-NEXT: strh w8, [sp, #10]
20 ; CHECK-NEXT: ldr d2, [sp, #8]
21 ; CHECK-NEXT: lsl z2.h, z2.h, #15
22 ; CHECK-NEXT: asr z2.h, z2.h, #15
23 ; CHECK-NEXT: and z2.h, z2.h, #0x1
24 ; CHECK-NEXT: cmpne p0.h, p0/z, z2.h, #0
25 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
26 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
27 ; CHECK-NEXT: add sp, sp, #16
29 %sel = select <2 x i1> %mask, <2 x half> %op1, <2 x half> %op2
33 define <4 x half> @select_v4f16(<4 x half> %op1, <4 x half> %op2, <4 x i1> %mask) {
34 ; CHECK-LABEL: select_v4f16:
36 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
37 ; CHECK-NEXT: ptrue p0.h
38 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
39 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
40 ; CHECK-NEXT: lsl z2.h, z2.h, #15
41 ; CHECK-NEXT: asr z2.h, z2.h, #15
42 ; CHECK-NEXT: and z2.h, z2.h, #0x1
43 ; CHECK-NEXT: cmpne p0.h, p0/z, z2.h, #0
44 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
45 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
47 %sel = select <4 x i1> %mask, <4 x half> %op1, <4 x half> %op2
51 define <8 x half> @select_v8f16(<8 x half> %op1, <8 x half> %op2, <8 x i1> %mask) {
52 ; CHECK-LABEL: select_v8f16:
54 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
55 ; CHECK-NEXT: ptrue p0.h
56 ; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
57 ; CHECK-NEXT: // kill: def $q1 killed $q1 def $z1
58 ; CHECK-NEXT: uunpklo z2.h, z2.b
59 ; CHECK-NEXT: lsl z2.h, z2.h, #15
60 ; CHECK-NEXT: asr z2.h, z2.h, #15
61 ; CHECK-NEXT: and z2.h, z2.h, #0x1
62 ; CHECK-NEXT: cmpne p0.h, p0/z, z2.h, #0
63 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
64 ; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
66 %sel = select <8 x i1> %mask, <8 x half> %op1, <8 x half> %op2
70 define void @select_v16f16(ptr %a, ptr %b) {
71 ; CHECK-LABEL: select_v16f16:
73 ; CHECK-NEXT: ptrue p0.h, vl8
74 ; CHECK-NEXT: ldp q0, q2, [x0]
75 ; CHECK-NEXT: ldp q1, q3, [x1]
76 ; CHECK-NEXT: fcmeq p1.h, p0/z, z0.h, z1.h
77 ; CHECK-NEXT: fcmeq p0.h, p0/z, z2.h, z3.h
78 ; CHECK-NEXT: sel z0.h, p1, z0.h, z1.h
79 ; CHECK-NEXT: sel z1.h, p0, z2.h, z3.h
80 ; CHECK-NEXT: stp q0, q1, [x0]
82 %op1 = load <16 x half>, ptr %a
83 %op2 = load <16 x half>, ptr %b
84 %mask = fcmp oeq <16 x half> %op1, %op2
85 %sel = select <16 x i1> %mask, <16 x half> %op1, <16 x half> %op2
86 store <16 x half> %sel, ptr %a
90 define <2 x float> @select_v2f32(<2 x float> %op1, <2 x float> %op2, <2 x i1> %mask) {
91 ; CHECK-LABEL: select_v2f32:
93 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
94 ; CHECK-NEXT: ptrue p0.s
95 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
96 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
97 ; CHECK-NEXT: lsl z2.s, z2.s, #31
98 ; CHECK-NEXT: asr z2.s, z2.s, #31
99 ; CHECK-NEXT: and z2.s, z2.s, #0x1
100 ; CHECK-NEXT: cmpne p0.s, p0/z, z2.s, #0
101 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s
102 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
104 %sel = select <2 x i1> %mask, <2 x float> %op1, <2 x float> %op2
108 define <4 x float> @select_v4f32(<4 x float> %op1, <4 x float> %op2, <4 x i1> %mask) {
109 ; CHECK-LABEL: select_v4f32:
111 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
112 ; CHECK-NEXT: ptrue p0.s
113 ; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
114 ; CHECK-NEXT: // kill: def $q1 killed $q1 def $z1
115 ; CHECK-NEXT: uunpklo z2.s, z2.h
116 ; CHECK-NEXT: lsl z2.s, z2.s, #31
117 ; CHECK-NEXT: asr z2.s, z2.s, #31
118 ; CHECK-NEXT: and z2.s, z2.s, #0x1
119 ; CHECK-NEXT: cmpne p0.s, p0/z, z2.s, #0
120 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s
121 ; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
123 %sel = select <4 x i1> %mask, <4 x float> %op1, <4 x float> %op2
127 define void @select_v8f32(ptr %a, ptr %b) {
128 ; CHECK-LABEL: select_v8f32:
130 ; CHECK-NEXT: ptrue p0.s, vl4
131 ; CHECK-NEXT: ldp q0, q2, [x0]
132 ; CHECK-NEXT: ldp q1, q3, [x1]
133 ; CHECK-NEXT: fcmeq p1.s, p0/z, z0.s, z1.s
134 ; CHECK-NEXT: fcmeq p0.s, p0/z, z2.s, z3.s
135 ; CHECK-NEXT: sel z0.s, p1, z0.s, z1.s
136 ; CHECK-NEXT: sel z1.s, p0, z2.s, z3.s
137 ; CHECK-NEXT: stp q0, q1, [x0]
139 %op1 = load <8 x float>, ptr %a
140 %op2 = load <8 x float>, ptr %b
141 %mask = fcmp oeq <8 x float> %op1, %op2
142 %sel = select <8 x i1> %mask, <8 x float> %op1, <8 x float> %op2
143 store <8 x float> %sel, ptr %a
147 define <1 x double> @select_v1f64(<1 x double> %op1, <1 x double> %op2, <1 x i1> %mask) {
148 ; CHECK-LABEL: select_v1f64:
150 ; CHECK-NEXT: tst w0, #0x1
151 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
152 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
153 ; CHECK-NEXT: csetm x8, ne
154 ; CHECK-NEXT: mvn x9, x8
155 ; CHECK-NEXT: mov z2.d, x8
156 ; CHECK-NEXT: mov z3.d, x9
157 ; CHECK-NEXT: and z0.d, z0.d, z2.d
158 ; CHECK-NEXT: and z1.d, z1.d, z3.d
159 ; CHECK-NEXT: orr z0.d, z0.d, z1.d
160 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
162 %sel = select <1 x i1> %mask, <1 x double> %op1, <1 x double> %op2
163 ret <1 x double> %sel
166 define <2 x double> @select_v2f64(<2 x double> %op1, <2 x double> %op2, <2 x i1> %mask) {
167 ; CHECK-LABEL: select_v2f64:
169 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
170 ; CHECK-NEXT: ptrue p0.d
171 ; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
172 ; CHECK-NEXT: // kill: def $q1 killed $q1 def $z1
173 ; CHECK-NEXT: uunpklo z2.d, z2.s
174 ; CHECK-NEXT: lsl z2.d, z2.d, #63
175 ; CHECK-NEXT: asr z2.d, z2.d, #63
176 ; CHECK-NEXT: and z2.d, z2.d, #0x1
177 ; CHECK-NEXT: cmpne p0.d, p0/z, z2.d, #0
178 ; CHECK-NEXT: sel z0.d, p0, z0.d, z1.d
179 ; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
181 %sel = select <2 x i1> %mask, <2 x double> %op1, <2 x double> %op2
182 ret <2 x double> %sel
185 define void @select_v4f64(ptr %a, ptr %b) {
186 ; CHECK-LABEL: select_v4f64:
188 ; CHECK-NEXT: ptrue p0.d, vl2
189 ; CHECK-NEXT: ldp q0, q2, [x0]
190 ; CHECK-NEXT: ldp q1, q3, [x1]
191 ; CHECK-NEXT: fcmeq p1.d, p0/z, z0.d, z1.d
192 ; CHECK-NEXT: fcmeq p0.d, p0/z, z2.d, z3.d
193 ; CHECK-NEXT: sel z0.d, p1, z0.d, z1.d
194 ; CHECK-NEXT: sel z1.d, p0, z2.d, z3.d
195 ; CHECK-NEXT: stp q0, q1, [x0]
197 %op1 = load <4 x double>, ptr %a
198 %op2 = load <4 x double>, ptr %b
199 %mask = fcmp oeq <4 x double> %op1, %op2
200 %sel = select <4 x i1> %mask, <4 x double> %op1, <4 x double> %op2
201 store <4 x double> %sel, ptr %a