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 <2 x half> @select_v2f16(<2 x half> %op1, <2 x half> %op2, i1 %mask) {
8 ; CHECK-LABEL: select_v2f16:
10 ; CHECK-NEXT: ptrue p0.h
11 ; CHECK-NEXT: mov z2.h, w0
12 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
13 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
14 ; CHECK-NEXT: and z2.h, z2.h, #0x1
15 ; CHECK-NEXT: cmpne p0.h, p0/z, z2.h, #0
16 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
17 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
19 %sel = select i1 %mask, <2 x half> %op1, <2 x half> %op2
23 define <4 x half> @select_v4f16(<4 x half> %op1, <4 x half> %op2, i1 %mask) {
24 ; CHECK-LABEL: select_v4f16:
26 ; CHECK-NEXT: ptrue p0.h
27 ; CHECK-NEXT: mov z2.h, w0
28 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
29 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
30 ; CHECK-NEXT: and z2.h, z2.h, #0x1
31 ; CHECK-NEXT: cmpne p0.h, p0/z, z2.h, #0
32 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
33 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
35 %sel = select i1 %mask, <4 x half> %op1, <4 x half> %op2
39 define <8 x half> @select_v8f16(<8 x half> %op1, <8 x half> %op2, i1 %mask) {
40 ; CHECK-LABEL: select_v8f16:
42 ; CHECK-NEXT: ptrue p0.h
43 ; CHECK-NEXT: mov z2.h, w0
44 ; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
45 ; CHECK-NEXT: // kill: def $q1 killed $q1 def $z1
46 ; CHECK-NEXT: and z2.h, z2.h, #0x1
47 ; CHECK-NEXT: cmpne p0.h, p0/z, z2.h, #0
48 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
49 ; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
51 %sel = select i1 %mask, <8 x half> %op1, <8 x half> %op2
55 define void @select_v16f16(ptr %a, ptr %b, i1 %mask) {
56 ; CHECK-LABEL: select_v16f16:
58 ; CHECK-NEXT: ptrue p0.h
59 ; CHECK-NEXT: mov z0.h, w2
60 ; CHECK-NEXT: and z0.h, z0.h, #0x1
61 ; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, #0
62 ; CHECK-NEXT: ldr q0, [x0]
63 ; CHECK-NEXT: ldr q1, [x0, #16]
64 ; CHECK-NEXT: ldr q2, [x1]
65 ; CHECK-NEXT: ldr q3, [x1, #16]
66 ; CHECK-NEXT: sel z0.h, p0, z0.h, z2.h
67 ; CHECK-NEXT: sel z1.h, p0, z1.h, z3.h
68 ; CHECK-NEXT: stp q0, q1, [x0]
70 %op1 = load volatile <16 x half>, ptr %a
71 %op2 = load volatile <16 x half>, ptr %b
72 %sel = select i1 %mask, <16 x half> %op1, <16 x half> %op2
73 store <16 x half> %sel, ptr %a
77 define <2 x float> @select_v2f32(<2 x float> %op1, <2 x float> %op2, i1 %mask) {
78 ; CHECK-LABEL: select_v2f32:
80 ; CHECK-NEXT: ptrue p0.s
81 ; CHECK-NEXT: and w8, w0, #0x1
82 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
83 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
84 ; CHECK-NEXT: mov z2.s, w8
85 ; CHECK-NEXT: cmpne p0.s, p0/z, z2.s, #0
86 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s
87 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
89 %sel = select i1 %mask, <2 x float> %op1, <2 x float> %op2
93 define <4 x float> @select_v4f32(<4 x float> %op1, <4 x float> %op2, i1 %mask) {
94 ; CHECK-LABEL: select_v4f32:
96 ; CHECK-NEXT: ptrue p0.s
97 ; CHECK-NEXT: and w8, w0, #0x1
98 ; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
99 ; CHECK-NEXT: // kill: def $q1 killed $q1 def $z1
100 ; CHECK-NEXT: mov z2.s, w8
101 ; CHECK-NEXT: cmpne p0.s, p0/z, z2.s, #0
102 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s
103 ; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
105 %sel = select i1 %mask, <4 x float> %op1, <4 x float> %op2
109 define void @select_v8f32(ptr %a, ptr %b, i1 %mask) {
110 ; CHECK-LABEL: select_v8f32:
112 ; CHECK-NEXT: ptrue p0.s
113 ; CHECK-NEXT: and w8, w2, #0x1
114 ; CHECK-NEXT: mov z0.s, w8
115 ; CHECK-NEXT: cmpne p0.s, p0/z, z0.s, #0
116 ; CHECK-NEXT: ldr q0, [x0]
117 ; CHECK-NEXT: ldr q1, [x0, #16]
118 ; CHECK-NEXT: ldr q2, [x1]
119 ; CHECK-NEXT: ldr q3, [x1, #16]
120 ; CHECK-NEXT: sel z0.s, p0, z0.s, z2.s
121 ; CHECK-NEXT: sel z1.s, p0, z1.s, z3.s
122 ; CHECK-NEXT: stp q0, q1, [x0]
124 %op1 = load volatile <8 x float>, ptr %a
125 %op2 = load volatile <8 x float>, ptr %b
126 %sel = select i1 %mask, <8 x float> %op1, <8 x float> %op2
127 store <8 x float> %sel, ptr %a
131 define <1 x double> @select_v1f64(<1 x double> %op1, <1 x double> %op2, i1 %mask) {
132 ; CHECK-LABEL: select_v1f64:
134 ; CHECK-NEXT: tst w0, #0x1
135 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $z1
136 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0
137 ; CHECK-NEXT: csetm x8, ne
138 ; CHECK-NEXT: mvn x9, x8
139 ; CHECK-NEXT: mov z2.d, x8
140 ; CHECK-NEXT: mov z3.d, x9
141 ; CHECK-NEXT: and z0.d, z0.d, z2.d
142 ; CHECK-NEXT: and z1.d, z1.d, z3.d
143 ; CHECK-NEXT: orr z0.d, z0.d, z1.d
144 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
146 %sel = select i1 %mask, <1 x double> %op1, <1 x double> %op2
147 ret <1 x double> %sel
150 define <2 x double> @select_v2f64(<2 x double> %op1, <2 x double> %op2, i1 %mask) {
151 ; CHECK-LABEL: select_v2f64:
153 ; CHECK-NEXT: ptrue p0.d
154 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
155 ; CHECK-NEXT: and x8, x0, #0x1
156 ; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
157 ; CHECK-NEXT: // kill: def $q1 killed $q1 def $z1
158 ; CHECK-NEXT: mov z2.d, x8
159 ; CHECK-NEXT: cmpne p0.d, p0/z, z2.d, #0
160 ; CHECK-NEXT: sel z0.d, p0, z0.d, z1.d
161 ; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
163 %sel = select i1 %mask, <2 x double> %op1, <2 x double> %op2
164 ret <2 x double> %sel
167 define void @select_v4f64(ptr %a, ptr %b, i1 %mask) {
168 ; CHECK-LABEL: select_v4f64:
170 ; CHECK-NEXT: ptrue p0.d
171 ; CHECK-NEXT: // kill: def $w2 killed $w2 def $x2
172 ; CHECK-NEXT: and x8, x2, #0x1
173 ; CHECK-NEXT: mov z0.d, x8
174 ; CHECK-NEXT: cmpne p0.d, p0/z, z0.d, #0
175 ; CHECK-NEXT: ldr q0, [x0]
176 ; CHECK-NEXT: ldr q1, [x0, #16]
177 ; CHECK-NEXT: ldr q2, [x1]
178 ; CHECK-NEXT: ldr q3, [x1, #16]
179 ; CHECK-NEXT: sel z0.d, p0, z0.d, z2.d
180 ; CHECK-NEXT: sel z1.d, p0, z1.d, z3.d
181 ; CHECK-NEXT: stp q0, q1, [x0]
183 %op1 = load volatile <4 x double>, ptr %a
184 %op2 = load volatile <4 x double>, ptr %b
185 %sel = select i1 %mask, <4 x double> %op1, <4 x double> %op2
186 store <4 x double> %sel, ptr %a