Debian Codegraph @

llvm/test/CodeGen/PowerPC/xxeval-vselect-x-nand.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, B, nand(B, C)) for <4 x i32>
14 define <4 x i32> @ternary_A_B_nand_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
15 ; CHECK-LABEL: ternary_A_B_nand_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, 227
21 ; CHECK-NEXT: blr
22 entry:
23 %and = and <4 x i32> %B, %C
24 %nand = xor <4 x i32> %and, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector nand operation
25 %res = select <4 x i1> %A, <4 x i32> %B, <4 x i32> %nand
26 ret <4 x i32> %res
27 }
28
29 ; Function to test ternary(A, B, nand(B, C)) for <2 x i64>
30 define <2 x i64> @ternary_A_B_nand_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
31 ; CHECK-LABEL: ternary_A_B_nand_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, 227
38 ; CHECK-NEXT: blr
39 entry:
40 %and = and <2 x i64> %B, %C
41 %nand = xor <2 x i64> %and, <i64 -1, i64 -1> ; Vector nand operation
42 %res = select <2 x i1> %A, <2 x i64> %B, <2 x i64> %nand
43 ret <2 x i64> %res
44 }
45
46 ; Function to test ternary(A, B, nand(B, C)) for <16 x i8>
47 define <16 x i8> @ternary_A_B_nand_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
48 ; CHECK-LABEL: ternary_A_B_nand_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, 227
54 ; CHECK-NEXT: blr
55 entry:
56 %and = and <16 x i8> %B, %C
57 %nand = xor <16 x i8> %and, <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 nand operation
58 %res = select <16 x i1> %A, <16 x i8> %B, <16 x i8> %nand
59 ret <16 x i8> %res
60 }
61
62 ; Function to test ternary(A, B, nand(B, C)) for <8 x i16>
63 define <8 x i16> @ternary_A_B_nand_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
64 ; CHECK-LABEL: ternary_A_B_nand_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, 227
70 ; CHECK-NEXT: blr
71 entry:
72 %and = and <8 x i16> %B, %C
73 %nand = xor <8 x i16> %and, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector nand operation
74 %res = select <8 x i1> %A, <8 x i16> %B, <8 x i16> %nand
75 ret <8 x i16> %res
76 }
77
78 ; Function to test ternary(A, C, nand(B, C)) for <4 x i32>
79 define <4 x i32> @ternary_A_C_nand_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
80 ; CHECK-LABEL: ternary_A_C_nand_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, 229
86 ; CHECK-NEXT: blr
87 entry:
88 %and = and <4 x i32> %B, %C
89 %nand = xor <4 x i32> %and, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector nand operation
90 %res = select <4 x i1> %A, <4 x i32> %C, <4 x i32> %nand
91 ret <4 x i32> %res
92 }
93
94 ; Function to test ternary(A, C, nand(B, C)) for <2 x i64>
95 define <2 x i64> @ternary_A_C_nand_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
96 ; CHECK-LABEL: ternary_A_C_nand_BC_2x64:
97 ; CHECK: # %bb.0: # %entry
98 ; CHECK-NEXT: xxlxor v5, v5, v5
99 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
100 ; CHECK-NEXT: vsld v2, v2, v5
101 ; CHECK-NEXT: vsrad v2, v2, v5
102 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 229
103 ; CHECK-NEXT: blr
104 entry:
105 %and = and <2 x i64> %B, %C
106 %nand = xor <2 x i64> %and, <i64 -1, i64 -1> ; Vector nand operation
107 %res = select <2 x i1> %A, <2 x i64> %C, <2 x i64> %nand
108 ret <2 x i64> %res
109 }
110
111 ; Function to test ternary(A, C, nand(B, C)) for <16 x i8>
112 define <16 x i8> @ternary_A_C_nand_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
113 ; CHECK-LABEL: ternary_A_C_nand_BC_16x8:
114 ; CHECK: # %bb.0: # %entry
115 ; CHECK-NEXT: xxspltib v5, 7
116 ; CHECK-NEXT: vslb v2, v2, v5
117 ; CHECK-NEXT: vsrab v2, v2, v5
118 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 229
119 ; CHECK-NEXT: blr
120 entry:
121 %and = and <16 x i8> %B, %C
122 %nand = xor <16 x i8> %and, <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 nand operation
123 %res = select <16 x i1> %A, <16 x i8> %C, <16 x i8> %nand
124 ret <16 x i8> %res
125 }
126
127 ; Function to test ternary(A, C, nand(B, C)) for <8 x i16>
128 define <8 x i16> @ternary_A_C_nand_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
129 ; CHECK-LABEL: ternary_A_C_nand_BC_8x16:
130 ; CHECK: # %bb.0: # %entry
131 ; CHECK-NEXT: xxspltiw v5, 983055
132 ; CHECK-NEXT: vslh v2, v2, v5
133 ; CHECK-NEXT: vsrah v2, v2, v5
134 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 229
135 ; CHECK-NEXT: blr
136 entry:
137 %and = and <8 x i16> %B, %C
138 %nand = xor <8 x i16> %and, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector nand operation
139 %res = select <8 x i1> %A, <8 x i16> %C, <8 x i16> %nand
140 ret <8 x i16> %res
141 }
142
143 ; Function to test ternary(A, xor(B, C), nand(B, C)) for <4 x i32>
144 define <4 x i32> @ternary_A_xor_BC_nand_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
145 ; CHECK-LABEL: ternary_A_xor_BC_nand_BC_4x32:
146 ; CHECK: # %bb.0: # %entry
147 ; CHECK-NEXT: xxleqv v5, v5, v5
148 ; CHECK-NEXT: vslw v2, v2, v5
149 ; CHECK-NEXT: vsraw v2, v2, v5
150 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 230
151 ; CHECK-NEXT: blr
152 entry:
153 %xor = xor <4 x i32> %B, %C
154 %and = and <4 x i32> %B, %C
155 %nand = xor <4 x i32> %and, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector nand operation
156 %res = select <4 x i1> %A, <4 x i32> %xor, <4 x i32> %nand
157 ret <4 x i32> %res
158 }
159
160 ; Function to test ternary(A, xor(B, C), nand(B, C)) for <2 x i64>
161 define <2 x i64> @ternary_A_xor_BC_nand_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
162 ; CHECK-LABEL: ternary_A_xor_BC_nand_BC_2x64:
163 ; CHECK: # %bb.0: # %entry
164 ; CHECK-NEXT: xxlxor v5, v5, v5
165 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
166 ; CHECK-NEXT: vsld v2, v2, v5
167 ; CHECK-NEXT: vsrad v2, v2, v5
168 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 230
169 ; CHECK-NEXT: blr
170 entry:
171 %xor = xor <2 x i64> %B, %C
172 %and = and <2 x i64> %B, %C
173 %nand = xor <2 x i64> %and, <i64 -1, i64 -1> ; Vector nand operation
174 %res = select <2 x i1> %A, <2 x i64> %xor, <2 x i64> %nand
175 ret <2 x i64> %res
176 }
177
178 ; Function to test ternary(A, xor(B, C), nand(B, C)) for <16 x i8>
179 define <16 x i8> @ternary_A_xor_BC_nand_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
180 ; CHECK-LABEL: ternary_A_xor_BC_nand_BC_16x8:
181 ; CHECK: # %bb.0: # %entry
182 ; CHECK-NEXT: xxspltib v5, 7
183 ; CHECK-NEXT: vslb v2, v2, v5
184 ; CHECK-NEXT: vsrab v2, v2, v5
185 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 230
186 ; CHECK-NEXT: blr
187 entry:
188 %xor = xor <16 x i8> %B, %C
189 %and = and <16 x i8> %B, %C
190 %nand = xor <16 x i8> %and, <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 nand operation
191 %res = select <16 x i1> %A, <16 x i8> %xor, <16 x i8> %nand
192 ret <16 x i8> %res
193 }
194
195 ; Function to test ternary(A, xor(B, C), nand(B, C)) for <8 x i16>
196 define <8 x i16> @ternary_A_xor_BC_nand_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
197 ; CHECK-LABEL: ternary_A_xor_BC_nand_BC_8x16:
198 ; CHECK: # %bb.0: # %entry
199 ; CHECK-NEXT: xxspltiw v5, 983055
200 ; CHECK-NEXT: vslh v2, v2, v5
201 ; CHECK-NEXT: vsrah v2, v2, v5
202 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 230
203 ; CHECK-NEXT: blr
204 entry:
205 %xor = xor <8 x i16> %B, %C
206 %and = and <8 x i16> %B, %C
207 %nand = xor <8 x i16> %and, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector nand operation
208 %res = select <8 x i1> %A, <8 x i16> %xor, <8 x i16> %nand
209 ret <8 x i16> %res
210 }
211
212 ; Function to test ternary(A, or(B, C), nand(B, C)) for <4 x i32>
213 define <4 x i32> @ternary_A_or_BC_nand_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
214 ; CHECK-LABEL: ternary_A_or_BC_nand_BC_4x32:
215 ; CHECK: # %bb.0: # %entry
216 ; CHECK-NEXT: xxleqv v5, v5, v5
217 ; CHECK-NEXT: vslw v2, v2, v5
218 ; CHECK-NEXT: vsraw v2, v2, v5
219 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 231
220 ; CHECK-NEXT: blr
221 entry:
222 %or = or <4 x i32> %B, %C
223 %and = and <4 x i32> %B, %C
224 %nand = xor <4 x i32> %and, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector nand operation
225 %res = select <4 x i1> %A, <4 x i32> %or, <4 x i32> %nand
226 ret <4 x i32> %res
227 }
228
229 ; Function to test ternary(A, or(B, C), nand(B, C)) for <2 x i64>
230 define <2 x i64> @ternary_A_or_BC_nand_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
231 ; CHECK-LABEL: ternary_A_or_BC_nand_BC_2x64:
232 ; CHECK: # %bb.0: # %entry
233 ; CHECK-NEXT: xxlxor v5, v5, v5
234 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
235 ; CHECK-NEXT: vsld v2, v2, v5
236 ; CHECK-NEXT: vsrad v2, v2, v5
237 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 231
238 ; CHECK-NEXT: blr
239 entry:
240 %or = or <2 x i64> %B, %C
241 %and = and <2 x i64> %B, %C
242 %nand = xor <2 x i64> %and, <i64 -1, i64 -1> ; Vector nand operation
243 %res = select <2 x i1> %A, <2 x i64> %or, <2 x i64> %nand
244 ret <2 x i64> %res
245 }
246
247 ; Function to test ternary(A, or(B, C), nand(B, C)) for <16 x i8>
248 define <16 x i8> @ternary_A_or_BC_nand_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
249 ; CHECK-LABEL: ternary_A_or_BC_nand_BC_16x8:
250 ; CHECK: # %bb.0: # %entry
251 ; CHECK-NEXT: xxspltib v5, 7
252 ; CHECK-NEXT: vslb v2, v2, v5
253 ; CHECK-NEXT: vsrab v2, v2, v5
254 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 231
255 ; CHECK-NEXT: blr
256 entry:
257 %or = or <16 x i8> %B, %C
258 %and = and <16 x i8> %B, %C
259 %nand = xor <16 x i8> %and, <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 nand operation
260 %res = select <16 x i1> %A, <16 x i8> %or, <16 x i8> %nand
261 ret <16 x i8> %res
262 }
263
264 ; Function to test ternary(A, or(B, C), nand(B, C)) for <8 x i16>
265 define <8 x i16> @ternary_A_or_BC_nand_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
266 ; CHECK-LABEL: ternary_A_or_BC_nand_BC_8x16:
267 ; CHECK: # %bb.0: # %entry
268 ; CHECK-NEXT: xxspltiw v5, 983055
269 ; CHECK-NEXT: vslh v2, v2, v5
270 ; CHECK-NEXT: vsrah v2, v2, v5
271 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 231
272 ; CHECK-NEXT: blr
273 entry:
274 %or = or <8 x i16> %B, %C
275 %and = and <8 x i16> %B, %C
276 %nand = xor <8 x i16> %and, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector nand operation
277 %res = select <8 x i1> %A, <8 x i16> %or, <8 x i16> %nand
278 ret <8 x i16> %res
279 }
280
281 ; Function to test ternary(A, eqv(B, C), nand(B, C)) for <4 x i32>
282 define <4 x i32> @ternary_A_eqv_BC_nand_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
283 ; CHECK-LABEL: ternary_A_eqv_BC_nand_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, 233
289 ; CHECK-NEXT: blr
290 entry:
291 %xor = xor <4 x i32> %B, %C
292 %eqv = xor <4 x i32> %xor, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector eqv operation
293 %and = and <4 x i32> %B, %C
294 %nand = xor <4 x i32> %and, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector nand operation
295 %res = select <4 x i1> %A, <4 x i32> %eqv, <4 x i32> %nand
296 ret <4 x i32> %res
297 }
298
299 ; Function to test ternary(A, eqv(B, C), nand(B, C)) for <2 x i64>
300 define <2 x i64> @ternary_A_eqv_BC_nand_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
301 ; CHECK-LABEL: ternary_A_eqv_BC_nand_BC_2x64:
302 ; CHECK: # %bb.0: # %entry
303 ; CHECK-NEXT: xxlxor v5, v5, v5
304 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
305 ; CHECK-NEXT: vsld v2, v2, v5
306 ; CHECK-NEXT: vsrad v2, v2, v5
307 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 233
308 ; CHECK-NEXT: blr
309 entry:
310 %xor = xor <2 x i64> %B, %C
311 %eqv = xor <2 x i64> %xor, <i64 -1, i64 -1> ; Vector eqv operation
312 %and = and <2 x i64> %B, %C
313 %nand = xor <2 x i64> %and, <i64 -1, i64 -1> ; Vector nand operation
314 %res = select <2 x i1> %A, <2 x i64> %eqv, <2 x i64> %nand
315 ret <2 x i64> %res
316 }
317
318 ; Function to test ternary(A, eqv(B, C), nand(B, C)) for <16 x i8>
319 define <16 x i8> @ternary_A_eqv_BC_nand_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
320 ; CHECK-LABEL: ternary_A_eqv_BC_nand_BC_16x8:
321 ; CHECK: # %bb.0: # %entry
322 ; CHECK-NEXT: xxspltib v5, 7
323 ; CHECK-NEXT: vslb v2, v2, v5
324 ; CHECK-NEXT: vsrab v2, v2, v5
325 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 233
326 ; CHECK-NEXT: blr
327 entry:
328 %xor = xor <16 x i8> %B, %C
329 %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
330 %and = and <16 x i8> %B, %C
331 %nand = xor <16 x i8> %and, <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 nand operation
332 %res = select <16 x i1> %A, <16 x i8> %eqv, <16 x i8> %nand
333 ret <16 x i8> %res
334 }
335
336 ; Function to test ternary(A, eqv(B, C), nand(B, C)) for <8 x i16>
337 define <8 x i16> @ternary_A_eqv_BC_nand_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
338 ; CHECK-LABEL: ternary_A_eqv_BC_nand_BC_8x16:
339 ; CHECK: # %bb.0: # %entry
340 ; CHECK-NEXT: xxspltiw v5, 983055
341 ; CHECK-NEXT: vslh v2, v2, v5
342 ; CHECK-NEXT: vsrah v2, v2, v5
343 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 233
344 ; CHECK-NEXT: blr
345 entry:
346 %xor = xor <8 x i16> %B, %C
347 %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
348 %and = and <8 x i16> %B, %C
349 %nand = xor <8 x i16> %and, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector nand operation
350 %res = select <8 x i1> %A, <8 x i16> %eqv, <8 x i16> %nand
351 ret <8 x i16> %res
352 }