Debian Codegraph @

llvm/test/CodeGen/PowerPC/xxeval-vselect-x-or.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, and(B, C), or(B, C)) for <4 x i32>
14 define <4 x i32> @ternary_A_and_BC_or_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
15 ; CHECK-LABEL: ternary_A_and_BC_or_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, 113
21 ; CHECK-NEXT: blr
22 entry:
23 %and = and <4 x i32> %B, %C
24 %or = or <4 x i32> %B, %C
25 %res = select <4 x i1> %A, <4 x i32> %and, <4 x i32> %or
26 ret <4 x i32> %res
27 }
28
29 ; Function to test ternary(A, and(B, C), or(B, C)) for <2 x i64>
30 define <2 x i64> @ternary_A_and_BC_or_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
31 ; CHECK-LABEL: ternary_A_and_BC_or_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, 113
38 ; CHECK-NEXT: blr
39 entry:
40 %and = and <2 x i64> %B, %C
41 %or = or <2 x i64> %B, %C
42 %res = select <2 x i1> %A, <2 x i64> %and, <2 x i64> %or
43 ret <2 x i64> %res
44 }
45
46 ; Function to test ternary(A, and(B, C), or(B, C)) for <16 x i8>
47 define <16 x i8> @ternary_A_and_BC_or_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
48 ; CHECK-LABEL: ternary_A_and_BC_or_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, 113
54 ; CHECK-NEXT: blr
55 entry:
56 %and = and <16 x i8> %B, %C
57 %or = or <16 x i8> %B, %C
58 %res = select <16 x i1> %A, <16 x i8> %and, <16 x i8> %or
59 ret <16 x i8> %res
60 }
61
62 ; Function to test ternary(A, and(B, C), or(B, C)) for <8 x i16>
63 define <8 x i16> @ternary_A_and_BC_or_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
64 ; CHECK-LABEL: ternary_A_and_BC_or_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, 113
70 ; CHECK-NEXT: blr
71 entry:
72 %and = and <8 x i16> %B, %C
73 %or = or <8 x i16> %B, %C
74 %res = select <8 x i1> %A, <8 x i16> %and, <8 x i16> %or
75 ret <8 x i16> %res
76 }
77
78 ; Function to test ternary(A, B, or(B, C)) for <4 x i32>
79 define <4 x i32> @ternary_A_B_or_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
80 ; CHECK-LABEL: ternary_A_B_or_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, 115
86 ; CHECK-NEXT: blr
87 entry:
88 %or = or <4 x i32> %B, %C
89 %res = select <4 x i1> %A, <4 x i32> %B, <4 x i32> %or
90 ret <4 x i32> %res
91 }
92
93 ; Function to test ternary(A, B, or(B, C)) for <2 x i64>
94 define <2 x i64> @ternary_A_B_or_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
95 ; CHECK-LABEL: ternary_A_B_or_BC_2x64:
96 ; CHECK: # %bb.0: # %entry
97 ; CHECK-NEXT: xxlxor v5, v5, v5
98 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
99 ; CHECK-NEXT: vsld v2, v2, v5
100 ; CHECK-NEXT: vsrad v2, v2, v5
101 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 115
102 ; CHECK-NEXT: blr
103 entry:
104 %or = or <2 x i64> %B, %C
105 %res = select <2 x i1> %A, <2 x i64> %B, <2 x i64> %or
106 ret <2 x i64> %res
107 }
108
109 ; Function to test ternary(A, B, or(B, C)) for <16 x i8>
110 define <16 x i8> @ternary_A_B_or_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
111 ; CHECK-LABEL: ternary_A_B_or_BC_16x8:
112 ; CHECK: # %bb.0: # %entry
113 ; CHECK-NEXT: xxspltib v5, 7
114 ; CHECK-NEXT: vslb v2, v2, v5
115 ; CHECK-NEXT: vsrab v2, v2, v5
116 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 115
117 ; CHECK-NEXT: blr
118 entry:
119 %or = or <16 x i8> %B, %C
120 %res = select <16 x i1> %A, <16 x i8> %B, <16 x i8> %or
121 ret <16 x i8> %res
122 }
123
124 ; Function to test ternary(A, B, or(B, C)) for <8 x i16>
125 define <8 x i16> @ternary_A_B_or_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
126 ; CHECK-LABEL: ternary_A_B_or_BC_8x16:
127 ; CHECK: # %bb.0: # %entry
128 ; CHECK-NEXT: xxspltiw v5, 983055
129 ; CHECK-NEXT: vslh v2, v2, v5
130 ; CHECK-NEXT: vsrah v2, v2, v5
131 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 115
132 ; CHECK-NEXT: blr
133 entry:
134 %or = or <8 x i16> %B, %C
135 %res = select <8 x i1> %A, <8 x i16> %B, <8 x i16> %or
136 ret <8 x i16> %res
137 }
138
139 ; Function to test ternary(A, C, or(B, C)) for <4 x i32>
140 define <4 x i32> @ternary_A_C_or_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
141 ; CHECK-LABEL: ternary_A_C_or_BC_4x32:
142 ; CHECK: # %bb.0: # %entry
143 ; CHECK-NEXT: xxleqv v5, v5, v5
144 ; CHECK-NEXT: vslw v2, v2, v5
145 ; CHECK-NEXT: vsraw v2, v2, v5
146 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 117
147 ; CHECK-NEXT: blr
148 entry:
149 %or = or <4 x i32> %B, %C
150 %res = select <4 x i1> %A, <4 x i32> %C, <4 x i32> %or
151 ret <4 x i32> %res
152 }
153
154 ; Function to test ternary(A, C, or(B, C)) for <2 x i64>
155 define <2 x i64> @ternary_A_C_or_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
156 ; CHECK-LABEL: ternary_A_C_or_BC_2x64:
157 ; CHECK: # %bb.0: # %entry
158 ; CHECK-NEXT: xxlxor v5, v5, v5
159 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
160 ; CHECK-NEXT: vsld v2, v2, v5
161 ; CHECK-NEXT: vsrad v2, v2, v5
162 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 117
163 ; CHECK-NEXT: blr
164 entry:
165 %or = or <2 x i64> %B, %C
166 %res = select <2 x i1> %A, <2 x i64> %C, <2 x i64> %or
167 ret <2 x i64> %res
168 }
169
170 ; Function to test ternary(A, C, or(B, C)) for <16 x i8>
171 define <16 x i8> @ternary_A_C_or_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
172 ; CHECK-LABEL: ternary_A_C_or_BC_16x8:
173 ; CHECK: # %bb.0: # %entry
174 ; CHECK-NEXT: xxspltib v5, 7
175 ; CHECK-NEXT: vslb v2, v2, v5
176 ; CHECK-NEXT: vsrab v2, v2, v5
177 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 117
178 ; CHECK-NEXT: blr
179 entry:
180 %or = or <16 x i8> %B, %C
181 %res = select <16 x i1> %A, <16 x i8> %C, <16 x i8> %or
182 ret <16 x i8> %res
183 }
184
185 ; Function to test ternary(A, C, or(B, C)) for <8 x i16>
186 define <8 x i16> @ternary_A_C_or_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
187 ; CHECK-LABEL: ternary_A_C_or_BC_8x16:
188 ; CHECK: # %bb.0: # %entry
189 ; CHECK-NEXT: xxspltiw v5, 983055
190 ; CHECK-NEXT: vslh v2, v2, v5
191 ; CHECK-NEXT: vsrah v2, v2, v5
192 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 117
193 ; CHECK-NEXT: blr
194 entry:
195 %or = or <8 x i16> %B, %C
196 %res = select <8 x i1> %A, <8 x i16> %C, <8 x i16> %or
197 ret <8 x i16> %res
198 }
199
200 ; Function to test ternary(A, eqv(B,C), or(B, C)) for <4 x i32>
201 define <4 x i32> @ternary_A_eqv_BC_or_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
202 ; CHECK-LABEL: ternary_A_eqv_BC_or_BC_4x32:
203 ; CHECK: # %bb.0: # %entry
204 ; CHECK-NEXT: xxleqv v5, v5, v5
205 ; CHECK-NEXT: vslw v2, v2, v5
206 ; CHECK-NEXT: vsraw v2, v2, v5
207 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 121
208 ; CHECK-NEXT: blr
209 entry:
210 %xor = xor <4 x i32> %B, %C
211 %eqv = xor <4 x i32> %xor, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector eqv operation
212 %or = or <4 x i32> %B, %C
213 %res = select <4 x i1> %A, <4 x i32> %eqv, <4 x i32> %or
214 ret <4 x i32> %res
215 }
216
217 ; Function to test ternary(A, eqv(B,C), or(B, C)) for <2 x i64>
218 define <2 x i64> @ternary_A_eqv_BC_or_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
219 ; CHECK-LABEL: ternary_A_eqv_BC_or_BC_2x64:
220 ; CHECK: # %bb.0: # %entry
221 ; CHECK-NEXT: xxlxor v5, v5, v5
222 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
223 ; CHECK-NEXT: vsld v2, v2, v5
224 ; CHECK-NEXT: vsrad v2, v2, v5
225 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 121
226 ; CHECK-NEXT: blr
227 entry:
228 %xor = xor <2 x i64> %B, %C
229 %eqv = xor <2 x i64> %xor, <i64 -1, i64 -1> ; Vector eqv operation
230 %or = or <2 x i64> %B, %C
231 %res = select <2 x i1> %A, <2 x i64> %eqv, <2 x i64> %or
232 ret <2 x i64> %res
233 }
234
235 ; Function to test ternary(A, eqv(B,C), or(B, C)) for <16 x i8>
236 define <16 x i8> @ternary_A_eqv_BC_or_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
237 ; CHECK-LABEL: ternary_A_eqv_BC_or_BC_16x8:
238 ; CHECK: # %bb.0: # %entry
239 ; CHECK-NEXT: xxspltib v5, 7
240 ; CHECK-NEXT: vslb v2, v2, v5
241 ; CHECK-NEXT: vsrab v2, v2, v5
242 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 121
243 ; CHECK-NEXT: blr
244 entry:
245 %xor = xor <16 x i8> %B, %C
246 %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
247 %or = or <16 x i8> %B, %C
248 %res = select <16 x i1> %A, <16 x i8> %eqv, <16 x i8> %or
249 ret <16 x i8> %res
250 }
251
252 ; Function to test ternary(A, eqv(B,C), or(B, C)) for <8 x i16>
253 define <8 x i16> @ternary_A_eqv_BC_or_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
254 ; CHECK-LABEL: ternary_A_eqv_BC_or_BC_8x16:
255 ; CHECK: # %bb.0: # %entry
256 ; CHECK-NEXT: xxspltiw v5, 983055
257 ; CHECK-NEXT: vslh v2, v2, v5
258 ; CHECK-NEXT: vsrah v2, v2, v5
259 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 121
260 ; CHECK-NEXT: blr
261 entry:
262 %xor = xor <8 x i16> %B, %C
263 %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
264 %or = or <8 x i16> %B, %C
265 %res = select <8 x i1> %A, <8 x i16> %eqv, <8 x i16> %or
266 ret <8 x i16> %res
267 }
268
269 ; Function to test ternary(A, not(C), or(B, C)) for <4 x i32>
270 define <4 x i32> @ternary_A_not_C_or_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
271 ; CHECK-LABEL: ternary_A_not_C_or_BC_4x32:
272 ; CHECK: # %bb.0: # %entry
273 ; CHECK-NEXT: xxleqv v5, v5, v5
274 ; CHECK-NEXT: vslw v2, v2, v5
275 ; CHECK-NEXT: vsraw v2, v2, v5
276 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 122
277 ; CHECK-NEXT: blr
278 entry:
279 %not = xor <4 x i32> %C, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector not operation
280 %or = or <4 x i32> %B, %C
281 %res = select <4 x i1> %A, <4 x i32> %not, <4 x i32> %or
282 ret <4 x i32> %res
283 }
284
285 ; Function to test ternary(A, not(C), or(B, C)) for <2 x i64>
286 define <2 x i64> @ternary_A_not_C_or_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
287 ; CHECK-LABEL: ternary_A_not_C_or_BC_2x64:
288 ; CHECK: # %bb.0: # %entry
289 ; CHECK-NEXT: xxlxor v5, v5, v5
290 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
291 ; CHECK-NEXT: vsld v2, v2, v5
292 ; CHECK-NEXT: vsrad v2, v2, v5
293 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 122
294 ; CHECK-NEXT: blr
295 entry:
296 %not = xor <2 x i64> %C, <i64 -1, i64 -1> ; Vector not operation
297 %or = or <2 x i64> %B, %C
298 %res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %or
299 ret <2 x i64> %res
300 }
301
302 ; Function to test ternary(A, not(C), or(B, C)) for <16 x i8>
303 define <16 x i8> @ternary_A_not_C_or_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
304 ; CHECK-LABEL: ternary_A_not_C_or_BC_16x8:
305 ; CHECK: # %bb.0: # %entry
306 ; CHECK-NEXT: xxspltib v5, 7
307 ; CHECK-NEXT: vslb v2, v2, v5
308 ; CHECK-NEXT: vsrab v2, v2, v5
309 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 122
310 ; CHECK-NEXT: blr
311 entry:
312 %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
313 %or = or <16 x i8> %B, %C
314 %res = select <16 x i1> %A, <16 x i8> %not, <16 x i8> %or
315 ret <16 x i8> %res
316 }
317
318 ; Function to test ternary(A, not(C), or(B, C)) for <8 x i16>
319 define <8 x i16> @ternary_A_not_C_or_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
320 ; CHECK-LABEL: ternary_A_not_C_or_BC_8x16:
321 ; CHECK: # %bb.0: # %entry
322 ; CHECK-NEXT: xxspltiw v5, 983055
323 ; CHECK-NEXT: vslh v2, v2, v5
324 ; CHECK-NEXT: vsrah v2, v2, v5
325 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 122
326 ; CHECK-NEXT: blr
327 entry:
328 %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
329 %or = or <8 x i16> %B, %C
330 %res = select <8 x i1> %A, <8 x i16> %not, <8 x i16> %or
331 ret <8 x i16> %res
332 }
333
334 ; Function to test ternary(A, not(B), or(B, C)) for <4 x i32>
335 define <4 x i32> @ternary_A_not_B_or_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
336 ; CHECK-LABEL: ternary_A_not_B_or_BC_4x32:
337 ; CHECK: # %bb.0: # %entry
338 ; CHECK-NEXT: xxleqv v5, v5, v5
339 ; CHECK-NEXT: vslw v2, v2, v5
340 ; CHECK-NEXT: vsraw v2, v2, v5
341 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 124
342 ; CHECK-NEXT: blr
343 entry:
344 %not = xor <4 x i32> %B, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector not operation
345 %or = or <4 x i32> %B, %C
346 %res = select <4 x i1> %A, <4 x i32> %not, <4 x i32> %or
347 ret <4 x i32> %res
348 }
349
350 ; Function to test ternary(A, not(B), or(B, C)) for <2 x i64>
351 define <2 x i64> @ternary_A_not_B_or_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
352 ; CHECK-LABEL: ternary_A_not_B_or_BC_2x64:
353 ; CHECK: # %bb.0: # %entry
354 ; CHECK-NEXT: xxlxor v5, v5, v5
355 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
356 ; CHECK-NEXT: vsld v2, v2, v5
357 ; CHECK-NEXT: vsrad v2, v2, v5
358 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 124
359 ; CHECK-NEXT: blr
360 entry:
361 %not = xor <2 x i64> %B, <i64 -1, i64 -1> ; Vector not operation
362 %or = or <2 x i64> %B, %C
363 %res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %or
364 ret <2 x i64> %res
365 }
366
367 ; Function to test ternary(A, not(B), or(B, C)) for <16 x i8>
368 define <16 x i8> @ternary_A_not_B_or_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
369 ; CHECK-LABEL: ternary_A_not_B_or_BC_16x8:
370 ; CHECK: # %bb.0: # %entry
371 ; CHECK-NEXT: xxspltib v5, 7
372 ; CHECK-NEXT: vslb v2, v2, v5
373 ; CHECK-NEXT: vsrab v2, v2, v5
374 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 124
375 ; CHECK-NEXT: blr
376 entry:
377 %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
378 %or = or <16 x i8> %B, %C
379 %res = select <16 x i1> %A, <16 x i8> %not, <16 x i8> %or
380 ret <16 x i8> %res
381 }
382
383 ; Function to test ternary(A, not(B), or(B, C)) for <8 x i16>
384 define <8 x i16> @ternary_A_not_B_or_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
385 ; CHECK-LABEL: ternary_A_not_B_or_BC_8x16:
386 ; CHECK: # %bb.0: # %entry
387 ; CHECK-NEXT: xxspltiw v5, 983055
388 ; CHECK-NEXT: vslh v2, v2, v5
389 ; CHECK-NEXT: vsrah v2, v2, v5
390 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 124
391 ; CHECK-NEXT: blr
392 entry:
393 %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
394 %or = or <8 x i16> %B, %C
395 %res = select <8 x i1> %A, <8 x i16> %not, <8 x i16> %or
396 ret <8 x i16> %res
397 }
398
399 ; Function to test ternary(A, nand(B,C), or(B, C)) for <4 x i32>
400 define <4 x i32> @ternary_A_nand_BC_or_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
401 ; CHECK-LABEL: ternary_A_nand_BC_or_BC_4x32:
402 ; CHECK: # %bb.0: # %entry
403 ; CHECK-NEXT: xxleqv v5, v5, v5
404 ; CHECK-NEXT: vslw v2, v2, v5
405 ; CHECK-NEXT: vsraw v2, v2, v5
406 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 126
407 ; CHECK-NEXT: blr
408 entry:
409 %and = and <4 x i32> %B, %C
410 %nand = xor <4 x i32> %and, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector nand operation
411 %or = or <4 x i32> %B, %C
412 %res = select <4 x i1> %A, <4 x i32> %nand, <4 x i32> %or
413 ret <4 x i32> %res
414 }
415
416 ; Function to test ternary(A, nand(B,C), or(B, C)) for <2 x i64>
417 define <2 x i64> @ternary_A_nand_BC_or_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
418 ; CHECK-LABEL: ternary_A_nand_BC_or_BC_2x64:
419 ; CHECK: # %bb.0: # %entry
420 ; CHECK-NEXT: xxlxor v5, v5, v5
421 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
422 ; CHECK-NEXT: vsld v2, v2, v5
423 ; CHECK-NEXT: vsrad v2, v2, v5
424 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 126
425 ; CHECK-NEXT: blr
426 entry:
427 %and = and <2 x i64> %B, %C
428 %nand = xor <2 x i64> %and, <i64 -1, i64 -1> ; Vector nand operation
429 %or = or <2 x i64> %B, %C
430 %res = select <2 x i1> %A, <2 x i64> %nand, <2 x i64> %or
431 ret <2 x i64> %res
432 }
433
434 ; Function to test ternary(A, nand(B,C), or(B, C)) for <16 x i8>
435 define <16 x i8> @ternary_A_nand_BC_or_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
436 ; CHECK-LABEL: ternary_A_nand_BC_or_BC_16x8:
437 ; CHECK: # %bb.0: # %entry
438 ; CHECK-NEXT: xxspltib v5, 7
439 ; CHECK-NEXT: vslb v2, v2, v5
440 ; CHECK-NEXT: vsrab v2, v2, v5
441 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 126
442 ; CHECK-NEXT: blr
443 entry:
444 %and = and <16 x i8> %B, %C
445 %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
446 %or = or <16 x i8> %B, %C
447 %res = select <16 x i1> %A, <16 x i8> %nand, <16 x i8> %or
448 ret <16 x i8> %res
449 }
450
451 ; Function to test ternary(A, nand(B,C), or(B, C)) for <8 x i16>
452 define <8 x i16> @ternary_A_nand_BC_or_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
453 ; CHECK-LABEL: ternary_A_nand_BC_or_BC_8x16:
454 ; CHECK: # %bb.0: # %entry
455 ; CHECK-NEXT: xxspltiw v5, 983055
456 ; CHECK-NEXT: vslh v2, v2, v5
457 ; CHECK-NEXT: vsrah v2, v2, v5
458 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 126
459 ; CHECK-NEXT: blr
460 entry:
461 %and = and <8 x i16> %B, %C
462 %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
463 %or = or <8 x i16> %B, %C
464 %res = select <8 x i1> %A, <8 x i16> %nand, <8 x i16> %or
465 ret <8 x i16> %res
466 }