Debian Codegraph @

llvm/test/CodeGen/PowerPC/xxeval-vselect-x-and.ll

raw
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; Test file to verify the emission of Vector Evaluate instructions when ternary operators are used.
3
4 ; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64le-unknown-unknown \
5 ; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s
6
7 ; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc-ibm-aix-xcoff \
8 ; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s
9
10 ; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64-ibm-aix-xcoff \
11 ; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s
12
13 ; Function to test ternary(A, xor(B, C), and(B, C)) for <4 x i32>
14 define <4 x i32> @ternary_A_xor_BC_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
15 ; CHECK-LABEL: ternary_A_xor_BC_and_BC_4x32:
16 ; CHECK: # %bb.0: # %entry
17 ; CHECK-NEXT: xxleqv v5, v5, v5
18 ; CHECK-NEXT: vslw v2, v2, v5
19 ; CHECK-NEXT: vsraw v2, v2, v5
20 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 22
21 ; CHECK-NEXT: blr
22 entry:
23 %xor = xor <4 x i32> %B, %C
24 %and = and <4 x i32> %B, %C
25 %res = select <4 x i1> %A, <4 x i32> %xor, <4 x i32> %and
26 ret <4 x i32> %res
27 }
28
29 ; Function to test ternary(A, xor(B, C), and(B, C)) for <2 x i64>
30 define <2 x i64> @ternary_A_xor_BC_and_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
31 ; CHECK-LABEL: ternary_A_xor_BC_and_BC_2x64:
32 ; CHECK: # %bb.0: # %entry
33 ; CHECK-NEXT: xxlxor v5, v5, v5
34 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
35 ; CHECK-NEXT: vsld v2, v2, v5
36 ; CHECK-NEXT: vsrad v2, v2, v5
37 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 22
38 ; CHECK-NEXT: blr
39 entry:
40 %xor = xor <2 x i64> %B, %C
41 %and = and <2 x i64> %B, %C
42 %res = select <2 x i1> %A, <2 x i64> %xor, <2 x i64> %and
43 ret <2 x i64> %res
44 }
45
46 ; Function to test ternary(A, xor(B, C), and(B, C)) for <16 x i8>
47 define <16 x i8> @ternary_A_xor_BC_and_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
48 ; CHECK-LABEL: ternary_A_xor_BC_and_BC_16x8:
49 ; CHECK: # %bb.0: # %entry
50 ; CHECK-NEXT: xxspltib v5, 7
51 ; CHECK-NEXT: vslb v2, v2, v5
52 ; CHECK-NEXT: vsrab v2, v2, v5
53 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 22
54 ; CHECK-NEXT: blr
55 entry:
56 %xor = xor <16 x i8> %B, %C
57 %and = and <16 x i8> %B, %C
58 %res = select <16 x i1> %A, <16 x i8> %xor, <16 x i8> %and
59 ret <16 x i8> %res
60 }
61
62 ; Function to test ternary(A, xor(B, C), and(B, C)) for <8 x i16>
63 define <8 x i16> @ternary_A_xor_BC_and_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
64 ; CHECK-LABEL: ternary_A_xor_BC_and_BC_8x16:
65 ; CHECK: # %bb.0: # %entry
66 ; CHECK-NEXT: xxspltiw v5, 983055
67 ; CHECK-NEXT: vslh v2, v2, v5
68 ; CHECK-NEXT: vsrah v2, v2, v5
69 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 22
70 ; CHECK-NEXT: blr
71 entry:
72 %xor = xor <8 x i16> %B, %C
73 %and = and <8 x i16> %B, %C
74 %res = select <8 x i1> %A, <8 x i16> %xor, <8 x i16> %and
75 ret <8 x i16> %res
76 }
77
78 ; Function to test ternary(A, nor(B, C), and(B, C)) for <4 x i32>
79 define <4 x i32> @ternary_A_nor_BC_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
80 ; CHECK-LABEL: ternary_A_nor_BC_and_BC_4x32:
81 ; CHECK: # %bb.0: # %entry
82 ; CHECK-NEXT: xxleqv v5, v5, v5
83 ; CHECK-NEXT: vslw v2, v2, v5
84 ; CHECK-NEXT: vsraw v2, v2, v5
85 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 24
86 ; CHECK-NEXT: blr
87 entry:
88 %or = or <4 x i32> %B, %C
89 %nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector NOR operation
90 %and = and <4 x i32> %B, %C
91 %res = select <4 x i1> %A, <4 x i32> %nor, <4 x i32> %and
92 ret <4 x i32> %res
93 }
94
95 ; Function to test ternary(A, nor(B, C), and(B, C)) for <2 x i64>
96 define <2 x i64> @ternary_A_nor_BC_and_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
97 ; CHECK-LABEL: ternary_A_nor_BC_and_BC_2x64:
98 ; CHECK: # %bb.0: # %entry
99 ; CHECK-NEXT: xxlxor v5, v5, v5
100 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
101 ; CHECK-NEXT: vsld v2, v2, v5
102 ; CHECK-NEXT: vsrad v2, v2, v5
103 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 24
104 ; CHECK-NEXT: blr
105 entry:
106 %or = or <2 x i64> %B, %C
107 %nor = xor <2 x i64> %or, <i64 -1, i64 -1> ; Vector NOR operation
108 %and = and <2 x i64> %B, %C
109 %res = select <2 x i1> %A, <2 x i64> %nor, <2 x i64> %and
110 ret <2 x i64> %res
111 }
112
113 ; Function to test ternary(A, nor(B, C), and(B, C)) for <16 x i8>
114 define <16 x i8> @ternary_A_nor_BC_and_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
115 ; CHECK-LABEL: ternary_A_nor_BC_and_BC_16x8:
116 ; CHECK: # %bb.0: # %entry
117 ; CHECK-NEXT: xxspltib v5, 7
118 ; CHECK-NEXT: vslb v2, v2, v5
119 ; CHECK-NEXT: vsrab v2, v2, v5
120 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 24
121 ; CHECK-NEXT: blr
122 entry:
123 %or = or <16 x i8> %B, %C
124 %nor = xor <16 x i8> %or, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1> ; Vector NOR operation
125 %and = and <16 x i8> %B, %C
126 %res = select <16 x i1> %A, <16 x i8> %nor, <16 x i8> %and
127 ret <16 x i8> %res
128 }
129
130 ; Function to test ternary(A, nor(B, C), and(B, C)) for <8 x i16>
131 define <8 x i16> @ternary_A_nor_BC_and_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
132 ; CHECK-LABEL: ternary_A_nor_BC_and_BC_8x16:
133 ; CHECK: # %bb.0: # %entry
134 ; CHECK-NEXT: xxspltiw v5, 983055
135 ; CHECK-NEXT: vslh v2, v2, v5
136 ; CHECK-NEXT: vsrah v2, v2, v5
137 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 24
138 ; CHECK-NEXT: blr
139 entry:
140 %or = or <8 x i16> %B, %C
141 %nor = xor <8 x i16> %or, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector NOR operation
142 %and = and <8 x i16> %B, %C
143 %res = select <8 x i1> %A, <8 x i16> %nor, <8 x i16> %and
144 ret <8 x i16> %res
145 }
146
147 ; Function to test ternary(A, eqv(B, C), and(B, C)) for <4 x i32>
148 define <4 x i32> @ternary_A_eqv_BC_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
149 ; CHECK-LABEL: ternary_A_eqv_BC_and_BC_4x32:
150 ; CHECK: # %bb.0: # %entry
151 ; CHECK-NEXT: xxleqv v5, v5, v5
152 ; CHECK-NEXT: vslw v2, v2, v5
153 ; CHECK-NEXT: vsraw v2, v2, v5
154 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 25
155 ; CHECK-NEXT: blr
156 entry:
157 %xor = xor <4 x i32> %B, %C
158 %eqv = xor <4 x i32> %xor, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector eqv operation
159 %and = and <4 x i32> %B, %C
160 %res = select <4 x i1> %A, <4 x i32> %eqv, <4 x i32> %and
161 ret <4 x i32> %res
162 }
163
164 ; Function to test ternary(A, eqv(B, C), and(B, C)) for <2 x i64>
165 define <2 x i64> @ternary_A_eqv_BC_and_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
166 ; CHECK-LABEL: ternary_A_eqv_BC_and_BC_2x64:
167 ; CHECK: # %bb.0: # %entry
168 ; CHECK-NEXT: xxlxor v5, v5, v5
169 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
170 ; CHECK-NEXT: vsld v2, v2, v5
171 ; CHECK-NEXT: vsrad v2, v2, v5
172 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 25
173 ; CHECK-NEXT: blr
174 entry:
175 %xor = xor <2 x i64> %B, %C
176 %eqv = xor <2 x i64> %xor, <i64 -1, i64 -1> ; Vector eqv operation
177 %and = and <2 x i64> %B, %C
178 %res = select <2 x i1> %A, <2 x i64> %eqv, <2 x i64> %and
179 ret <2 x i64> %res
180 }
181
182 ; Function to test ternary(A, eqv(B, C), and(B, C)) for <16 x i8>
183 define <16 x i8> @ternary_A_eqv_BC_and_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
184 ; CHECK-LABEL: ternary_A_eqv_BC_and_BC_16x8:
185 ; CHECK: # %bb.0: # %entry
186 ; CHECK-NEXT: xxspltib v5, 7
187 ; CHECK-NEXT: vslb v2, v2, v5
188 ; CHECK-NEXT: vsrab v2, v2, v5
189 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 25
190 ; CHECK-NEXT: blr
191 entry:
192 %xor = xor <16 x i8> %B, %C
193 %eqv = xor <16 x i8> %xor, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1> ; Vector eqv operation
194 %and = and <16 x i8> %B, %C
195 %res = select <16 x i1> %A, <16 x i8> %eqv, <16 x i8> %and
196 ret <16 x i8> %res
197 }
198
199 ; Function to test ternary(A, eqv(B, C), and(B, C)) for <8 x i16>
200 define <8 x i16> @ternary_A_eqv_BC_and_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
201 ; CHECK-LABEL: ternary_A_eqv_BC_and_BC_8x16:
202 ; CHECK: # %bb.0: # %entry
203 ; CHECK-NEXT: xxspltiw v5, 983055
204 ; CHECK-NEXT: vslh v2, v2, v5
205 ; CHECK-NEXT: vsrah v2, v2, v5
206 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 25
207 ; CHECK-NEXT: blr
208 entry:
209 %xor = xor <8 x i16> %B, %C
210 %eqv = xor <8 x i16> %xor, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector eqv operation
211 %and = and <8 x i16> %B, %C
212 %res = select <8 x i1> %A, <8 x i16> %eqv, <8 x i16> %and
213 ret <8 x i16> %res
214 }
215
216 ; Function to test ternary(A, not(C), and(B, C)) for <4 x i32>
217 define <4 x i32> @ternary_A_not_C_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
218 ; CHECK-LABEL: ternary_A_not_C_and_BC_4x32:
219 ; CHECK: # %bb.0: # %entry
220 ; CHECK-NEXT: xxleqv v5, v5, v5
221 ; CHECK-NEXT: vslw v2, v2, v5
222 ; CHECK-NEXT: vsraw v2, v2, v5
223 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 26
224 ; CHECK-NEXT: blr
225 entry:
226 %not = xor <4 x i32> %C, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector not operation
227 %and = and <4 x i32> %B, %C
228 %res = select <4 x i1> %A, <4 x i32> %not, <4 x i32> %and
229 ret <4 x i32> %res
230 }
231
232 ; Function to test ternary(A, not(C), and(B, C)) for <2 x i64>
233 define <2 x i64> @ternary_A_not_C_and_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
234 ; CHECK-LABEL: ternary_A_not_C_and_BC_2x64:
235 ; CHECK: # %bb.0: # %entry
236 ; CHECK-NEXT: xxlxor v5, v5, v5
237 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
238 ; CHECK-NEXT: vsld v2, v2, v5
239 ; CHECK-NEXT: vsrad v2, v2, v5
240 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 26
241 ; CHECK-NEXT: blr
242 entry:
243 %not = xor <2 x i64> %C, <i64 -1, i64 -1> ; Vector not operation
244 %and = and <2 x i64> %B, %C
245 %res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %and
246 ret <2 x i64> %res
247 }
248
249 ; Function to test ternary(A, not(C), and(B, C)) for <16 x i8>
250 define <16 x i8> @ternary_A_not_C_and_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
251 ; CHECK-LABEL: ternary_A_not_C_and_BC_16x8:
252 ; CHECK: # %bb.0: # %entry
253 ; CHECK-NEXT: xxspltib v5, 7
254 ; CHECK-NEXT: vslb v2, v2, v5
255 ; CHECK-NEXT: vsrab v2, v2, v5
256 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 26
257 ; CHECK-NEXT: blr
258 entry:
259 %not = xor <16 x i8> %C, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1> ; Vector not operation
260 %and = and <16 x i8> %B, %C
261 %res = select <16 x i1> %A, <16 x i8> %not, <16 x i8> %and
262 ret <16 x i8> %res
263 }
264
265 ; Function to test ternary(A, not(C), and(B, C)) for <8 x i16>
266 define <8 x i16> @ternary_A_not_C_and_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
267 ; CHECK-LABEL: ternary_A_not_C_and_BC_8x16:
268 ; CHECK: # %bb.0: # %entry
269 ; CHECK-NEXT: xxspltiw v5, 983055
270 ; CHECK-NEXT: vslh v2, v2, v5
271 ; CHECK-NEXT: vsrah v2, v2, v5
272 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 26
273 ; CHECK-NEXT: blr
274 entry:
275 %not = xor <8 x i16> %C, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector not operation
276 %and = and <8 x i16> %B, %C
277 %res = select <8 x i1> %A, <8 x i16> %not, <8 x i16> %and
278 ret <8 x i16> %res
279 }
280
281 ; Function to test ternary(A, not(B), and(B, C)) for <4 x i32>
282 define <4 x i32> @ternary_A_not_B_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
283 ; CHECK-LABEL: ternary_A_not_B_and_BC_4x32:
284 ; CHECK: # %bb.0: # %entry
285 ; CHECK-NEXT: xxleqv v5, v5, v5
286 ; CHECK-NEXT: vslw v2, v2, v5
287 ; CHECK-NEXT: vsraw v2, v2, v5
288 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 28
289 ; CHECK-NEXT: blr
290 entry:
291 %not = xor <4 x i32> %B, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector not operation
292 %and = and <4 x i32> %B, %C
293 %res = select <4 x i1> %A, <4 x i32> %not, <4 x i32> %and
294 ret <4 x i32> %res
295 }
296
297 ; Function to test ternary(A, not(B), and(B, C)) for <2 x i64>
298 define <2 x i64> @ternary_A_not_B_and_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
299 ; CHECK-LABEL: ternary_A_not_B_and_BC_2x64:
300 ; CHECK: # %bb.0: # %entry
301 ; CHECK-NEXT: xxlxor v5, v5, v5
302 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
303 ; CHECK-NEXT: vsld v2, v2, v5
304 ; CHECK-NEXT: vsrad v2, v2, v5
305 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 28
306 ; CHECK-NEXT: blr
307 entry:
308 %not = xor <2 x i64> %B, <i64 -1, i64 -1> ; Vector not operation
309 %and = and <2 x i64> %B, %C
310 %res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %and
311 ret <2 x i64> %res
312 }
313
314 ; Function to test ternary(A, not(B), and(B, C)) for <16 x i8>
315 define <16 x i8> @ternary_A_not_B_and_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
316 ; CHECK-LABEL: ternary_A_not_B_and_BC_16x8:
317 ; CHECK: # %bb.0: # %entry
318 ; CHECK-NEXT: xxspltib v5, 7
319 ; CHECK-NEXT: vslb v2, v2, v5
320 ; CHECK-NEXT: vsrab v2, v2, v5
321 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 28
322 ; CHECK-NEXT: blr
323 entry:
324 %not = xor <16 x i8> %B, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1> ; Vector not operation
325 %and = and <16 x i8> %B, %C
326 %res = select <16 x i1> %A, <16 x i8> %not, <16 x i8> %and
327 ret <16 x i8> %res
328 }
329
330 ; Function to test ternary(A, not(B), and(B, C)) for <8 x i16>
331 define <8 x i16> @ternary_A_not_B_and_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
332 ; CHECK-LABEL: ternary_A_not_B_and_BC_8x16:
333 ; CHECK: # %bb.0: # %entry
334 ; CHECK-NEXT: xxspltiw v5, 983055
335 ; CHECK-NEXT: vslh v2, v2, v5
336 ; CHECK-NEXT: vsrah v2, v2, v5
337 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 28
338 ; CHECK-NEXT: blr
339 entry:
340 %not = xor <8 x i16> %B, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector not operation
341 %and = and <8 x i16> %B, %C
342 %res = select <8 x i1> %A, <8 x i16> %not, <8 x i16> %and
343 ret <8 x i16> %res
344 }