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
3 ; RUN: llc -mattr=+sme -force-streaming-compatible-sve < %s | FileCheck %s
5 target triple = "aarch64-unknown-linux-gnu"
7 define <4 x i8> @select_v4i8(<4 x i8> %op1, <4 x i8> %op2, <4 x i1> %mask) {
8 ; CHECK-LABEL: select_v4i8:
10 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
11 ; CHECK-NEXT: ptrue p0.h
12 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
13 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
14 ; CHECK-NEXT: lsl z2.h, z2.h, #15
15 ; CHECK-NEXT: asr z2.h, z2.h, #15
16 ; CHECK-NEXT: and z2.h, z2.h, #0x1
17 ; CHECK-NEXT: cmpne p0.h, p0/z, z2.h, #0
18 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
19 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
21 %sel = select <4 x i1> %mask, <4 x i8> %op1, <4 x i8> %op2
25 define <8 x i8> @select_v8i8(<8 x i8> %op1, <8 x i8> %op2, <8 x i1> %mask) {
26 ; CHECK-LABEL: select_v8i8:
28 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
29 ; CHECK-NEXT: ptrue p0.b
30 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
31 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
32 ; CHECK-NEXT: lsl z2.b, z2.b, #7
33 ; CHECK-NEXT: asr z2.b, z2.b, #7
34 ; CHECK-NEXT: and z2.b, z2.b, #0x1
35 ; CHECK-NEXT: cmpne p0.b, p0/z, z2.b, #0
36 ; CHECK-NEXT: sel z0.b, p0, z0.b, z1.b
37 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
39 %sel = select <8 x i1> %mask, <8 x i8> %op1, <8 x i8> %op2
43 define <16 x i8> @select_v16i8(<16 x i8> %op1, <16 x i8> %op2, <16 x i1> %mask) {
44 ; CHECK-LABEL: select_v16i8:
46 ; CHECK-NEXT: // kill: def $q2 killed $q2 def $z2
47 ; CHECK-NEXT: ptrue p0.b
48 ; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
49 ; CHECK-NEXT: // kill: def $q1 killed $q1 def $z1
50 ; CHECK-NEXT: lsl z2.b, z2.b, #7
51 ; CHECK-NEXT: asr z2.b, z2.b, #7
52 ; CHECK-NEXT: and z2.b, z2.b, #0x1
53 ; CHECK-NEXT: cmpne p0.b, p0/z, z2.b, #0
54 ; CHECK-NEXT: sel z0.b, p0, z0.b, z1.b
55 ; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
57 %sel = select <16 x i1> %mask, <16 x i8> %op1, <16 x i8> %op2
61 define void @select_v32i8(ptr %a, ptr %b) {
62 ; CHECK-LABEL: select_v32i8:
64 ; CHECK-NEXT: ptrue p0.b, vl16
65 ; CHECK-NEXT: ldp q0, q2, [x0]
66 ; CHECK-NEXT: ldp q1, q3, [x1]
67 ; CHECK-NEXT: cmpeq p1.b, p0/z, z0.b, z1.b
68 ; CHECK-NEXT: cmpeq p0.b, p0/z, z2.b, z3.b
69 ; CHECK-NEXT: sel z0.b, p1, z0.b, z1.b
70 ; CHECK-NEXT: sel z1.b, p0, z2.b, z3.b
71 ; CHECK-NEXT: stp q0, q1, [x0]
73 %op1 = load <32 x i8>, ptr %a
74 %op2 = load <32 x i8>, ptr %b
75 %mask = icmp eq <32 x i8> %op1, %op2
76 %sel = select <32 x i1> %mask, <32 x i8> %op1, <32 x i8> %op2
77 store <32 x i8> %sel, ptr %a
81 define <2 x i16> @select_v2i16(<2 x i16> %op1, <2 x i16> %op2, <2 x i1> %mask) {
82 ; CHECK-LABEL: select_v2i16:
84 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
85 ; CHECK-NEXT: ptrue p0.s
86 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
87 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
88 ; CHECK-NEXT: lsl z2.s, z2.s, #31
89 ; CHECK-NEXT: asr z2.s, z2.s, #31
90 ; CHECK-NEXT: and z2.s, z2.s, #0x1
91 ; CHECK-NEXT: cmpne p0.s, p0/z, z2.s, #0
92 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s
93 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
95 %sel = select <2 x i1> %mask, <2 x i16> %op1, <2 x i16> %op2
99 define <4 x i16> @select_v4i16(<4 x i16> %op1, <4 x i16> %op2, <4 x i1> %mask) {
100 ; CHECK-LABEL: select_v4i16:
102 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
103 ; CHECK-NEXT: ptrue p0.h
104 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
105 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
106 ; CHECK-NEXT: lsl z2.h, z2.h, #15
107 ; CHECK-NEXT: asr z2.h, z2.h, #15
108 ; CHECK-NEXT: and z2.h, z2.h, #0x1
109 ; CHECK-NEXT: cmpne p0.h, p0/z, z2.h, #0
110 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
111 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
113 %sel = select <4 x i1> %mask, <4 x i16> %op1, <4 x i16> %op2
117 define <8 x i16> @select_v8i16(<8 x i16> %op1, <8 x i16> %op2, <8 x i1> %mask) {
118 ; CHECK-LABEL: select_v8i16:
120 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
121 ; CHECK-NEXT: ptrue p0.h
122 ; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
123 ; CHECK-NEXT: // kill: def $q1 killed $q1 def $z1
124 ; CHECK-NEXT: uunpklo z2.h, z2.b
125 ; CHECK-NEXT: lsl z2.h, z2.h, #15
126 ; CHECK-NEXT: asr z2.h, z2.h, #15
127 ; CHECK-NEXT: and z2.h, z2.h, #0x1
128 ; CHECK-NEXT: cmpne p0.h, p0/z, z2.h, #0
129 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
130 ; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
132 %sel = select <8 x i1> %mask, <8 x i16> %op1, <8 x i16> %op2
136 define void @select_v16i16(ptr %a, ptr %b) {
137 ; CHECK-LABEL: select_v16i16:
139 ; CHECK-NEXT: ptrue p0.h, vl8
140 ; CHECK-NEXT: ldp q0, q2, [x0]
141 ; CHECK-NEXT: ldp q1, q3, [x1]
142 ; CHECK-NEXT: cmpeq p1.h, p0/z, z0.h, z1.h
143 ; CHECK-NEXT: cmpeq p0.h, p0/z, z2.h, z3.h
144 ; CHECK-NEXT: sel z0.h, p1, z0.h, z1.h
145 ; CHECK-NEXT: sel z1.h, p0, z2.h, z3.h
146 ; CHECK-NEXT: stp q0, q1, [x0]
148 %op1 = load <16 x i16>, ptr %a
149 %op2 = load <16 x i16>, ptr %b
150 %mask = icmp eq <16 x i16> %op1, %op2
151 %sel = select <16 x i1> %mask, <16 x i16> %op1, <16 x i16> %op2
152 store <16 x i16> %sel, ptr %a
156 define <2 x i32> @select_v2i32(<2 x i32> %op1, <2 x i32> %op2, <2 x i1> %mask) {
157 ; CHECK-LABEL: select_v2i32:
159 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
160 ; CHECK-NEXT: ptrue p0.s
161 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
162 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
163 ; CHECK-NEXT: lsl z2.s, z2.s, #31
164 ; CHECK-NEXT: asr z2.s, z2.s, #31
165 ; CHECK-NEXT: and z2.s, z2.s, #0x1
166 ; CHECK-NEXT: cmpne p0.s, p0/z, z2.s, #0
167 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s
168 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
170 %sel = select <2 x i1> %mask, <2 x i32> %op1, <2 x i32> %op2
174 define <4 x i32> @select_v4i32(<4 x i32> %op1, <4 x i32> %op2, <4 x i1> %mask) {
175 ; CHECK-LABEL: select_v4i32:
177 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
178 ; CHECK-NEXT: ptrue p0.s
179 ; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
180 ; CHECK-NEXT: // kill: def $q1 killed $q1 def $z1
181 ; CHECK-NEXT: uunpklo z2.s, z2.h
182 ; CHECK-NEXT: lsl z2.s, z2.s, #31
183 ; CHECK-NEXT: asr z2.s, z2.s, #31
184 ; CHECK-NEXT: and z2.s, z2.s, #0x1
185 ; CHECK-NEXT: cmpne p0.s, p0/z, z2.s, #0
186 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s
187 ; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
189 %sel = select <4 x i1> %mask, <4 x i32> %op1, <4 x i32> %op2
193 define void @select_v8i32(ptr %a, ptr %b) {
194 ; CHECK-LABEL: select_v8i32:
196 ; CHECK-NEXT: ptrue p0.s, vl4
197 ; CHECK-NEXT: ldp q0, q2, [x0]
198 ; CHECK-NEXT: ldp q1, q3, [x1]
199 ; CHECK-NEXT: cmpeq p1.s, p0/z, z0.s, z1.s
200 ; CHECK-NEXT: cmpeq p0.s, p0/z, z2.s, z3.s
201 ; CHECK-NEXT: sel z0.s, p1, z0.s, z1.s
202 ; CHECK-NEXT: sel z1.s, p0, z2.s, z3.s
203 ; CHECK-NEXT: stp q0, q1, [x0]
205 %op1 = load <8 x i32>, ptr %a
206 %op2 = load <8 x i32>, ptr %b
207 %mask = icmp eq <8 x i32> %op1, %op2
208 %sel = select <8 x i1> %mask, <8 x i32> %op1, <8 x i32> %op2
209 store <8 x i32> %sel, ptr %a
213 define <1 x i64> @select_v1i64(<1 x i64> %op1, <1 x i64> %op2, <1 x i1> %mask) {
214 ; CHECK-LABEL: select_v1i64:
216 ; CHECK-NEXT: ptrue p0.d
217 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
218 ; CHECK-NEXT: and x8, x0, #0x1
219 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
220 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
221 ; CHECK-NEXT: mov z2.d, x8
222 ; CHECK-NEXT: cmpne p0.d, p0/z, z2.d, #0
223 ; CHECK-NEXT: sel z0.d, p0, z0.d, z1.d
224 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
226 %sel = select <1 x i1> %mask, <1 x i64> %op1, <1 x i64> %op2
230 define <2 x i64> @select_v2i64(<2 x i64> %op1, <2 x i64> %op2, <2 x i1> %mask) {
231 ; CHECK-LABEL: select_v2i64:
233 ; CHECK-NEXT: // kill: def $d2 killed $d2 def $z2
234 ; CHECK-NEXT: ptrue p0.d
235 ; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
236 ; CHECK-NEXT: // kill: def $q1 killed $q1 def $z1
237 ; CHECK-NEXT: uunpklo z2.d, z2.s
238 ; CHECK-NEXT: lsl z2.d, z2.d, #63
239 ; CHECK-NEXT: asr z2.d, z2.d, #63
240 ; CHECK-NEXT: and z2.d, z2.d, #0x1
241 ; CHECK-NEXT: cmpne p0.d, p0/z, z2.d, #0
242 ; CHECK-NEXT: sel z0.d, p0, z0.d, z1.d
243 ; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
245 %sel = select <2 x i1> %mask, <2 x i64> %op1, <2 x i64> %op2
249 define void @select_v4i64(ptr %a, ptr %b) {
250 ; CHECK-LABEL: select_v4i64:
252 ; CHECK-NEXT: ptrue p0.d, vl2
253 ; CHECK-NEXT: ldp q0, q2, [x0]
254 ; CHECK-NEXT: ldp q1, q3, [x1]
255 ; CHECK-NEXT: cmpeq p1.d, p0/z, z0.d, z1.d
256 ; CHECK-NEXT: cmpeq p0.d, p0/z, z2.d, z3.d
257 ; CHECK-NEXT: sel z0.d, p1, z0.d, z1.d
258 ; CHECK-NEXT: sel z1.d, p0, z2.d, z3.d
259 ; CHECK-NEXT: stp q0, q1, [x0]
261 %op1 = load <4 x i64>, ptr %a
262 %op2 = load <4 x i64>, ptr %b
263 %mask = icmp eq <4 x i64> %op1, %op2
264 %sel = select <4 x i1> %mask, <4 x i64> %op1, <4 x i64> %op2
265 store <4 x i64> %sel, ptr %a