Debian Codegraph @

llvm/test/CodeGen/PowerPC/xxeval-vselect-x-nor.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 selection 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), nor(B,C)) for <4 x i32>
14 define <4 x i32> @ternary_A_and_BC_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
15 ; CHECK-LABEL: ternary_A_and_BC_nor_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, 129
21 ; CHECK-NEXT: blr
22 entry:
23 %and = and <4 x i32> %B, %C
24 %or = or <4 x i32> %B, %C
25 %nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector NOR operation
26 %res = select <4 x i1> %A, <4 x i32> %and, <4 x i32> %nor
27 ret <4 x i32> %res
28 }
29
30 ; Function to test ternary(A, and(B, C), nor(B,C)) for <2 x i64>
31 define <2 x i64> @ternary_A_and_BC_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
32 ; CHECK-LABEL: ternary_A_and_BC_nor_BC_2x64:
33 ; CHECK: # %bb.0: # %entry
34 ; CHECK-NEXT: xxlxor v5, v5, v5
35 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
36 ; CHECK-NEXT: vsld v2, v2, v5
37 ; CHECK-NEXT: vsrad v2, v2, v5
38 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 129
39 ; CHECK-NEXT: blr
40 entry:
41 %and = and <2 x i64> %B, %C
42 %or = or <2 x i64> %B, %C
43 %nor = xor <2 x i64> %or, <i64 -1, i64 -1> ; Vector NOR operation
44 %res = select <2 x i1> %A, <2 x i64> %and, <2 x i64> %nor
45 ret <2 x i64> %res
46 }
47
48 ; Function to test ternary(A, and(B, C), nor(B,C)) for <16 x i8>
49 define <16 x i8> @ternary_A_and_BC_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
50 ; CHECK-LABEL: ternary_A_and_BC_nor_BC_16x8:
51 ; CHECK: # %bb.0: # %entry
52 ; CHECK-NEXT: xxspltib v5, 7
53 ; CHECK-NEXT: vslb v2, v2, v5
54 ; CHECK-NEXT: vsrab v2, v2, v5
55 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 129
56 ; CHECK-NEXT: blr
57 entry:
58 %and = and <16 x i8> %B, %C
59 %or = or <16 x i8> %B, %C
60 %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
61 %res = select <16 x i1> %A, <16 x i8> %and, <16 x i8> %nor
62 ret <16 x i8> %res
63 }
64
65 ; Function to test ternary(A, and(B, C), nor(B,C)) for <8 x i16>
66 define <8 x i16> @ternary_A_and_BC_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
67 ; CHECK-LABEL: ternary_A_and_BC_nor_BC_8x16:
68 ; CHECK: # %bb.0: # %entry
69 ; CHECK-NEXT: xxspltiw v5, 983055
70 ; CHECK-NEXT: vslh v2, v2, v5
71 ; CHECK-NEXT: vsrah v2, v2, v5
72 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 129
73 ; CHECK-NEXT: blr
74 entry:
75 %and = and <8 x i16> %B, %C
76 %or = or <8 x i16> %B, %C
77 %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
78 %res = select <8 x i1> %A, <8 x i16> %and, <8 x i16> %nor
79 ret <8 x i16> %res
80 }
81
82 ; Function to test ternary(A, B, nor(B,C)) for <4 x i32>
83 define <4 x i32> @ternary_A_B_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
84 ; CHECK-LABEL: ternary_A_B_nor_BC_4x32:
85 ; CHECK: # %bb.0: # %entry
86 ; CHECK-NEXT: xxleqv v5, v5, v5
87 ; CHECK-NEXT: vslw v2, v2, v5
88 ; CHECK-NEXT: vsraw v2, v2, v5
89 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 131
90 ; CHECK-NEXT: blr
91 entry:
92 %or = or <4 x i32> %B, %C
93 %nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector NOR operation
94 %res = select <4 x i1> %A, <4 x i32> %B, <4 x i32> %nor
95 ret <4 x i32> %res
96 }
97
98 ; Function to test ternary(A, B, nor(B,C)) for <2 x i64>
99 define <2 x i64> @ternary_A_B_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
100 ; CHECK-LABEL: ternary_A_B_nor_BC_2x64:
101 ; CHECK: # %bb.0: # %entry
102 ; CHECK-NEXT: xxlxor v5, v5, v5
103 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
104 ; CHECK-NEXT: vsld v2, v2, v5
105 ; CHECK-NEXT: vsrad v2, v2, v5
106 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 131
107 ; CHECK-NEXT: blr
108 entry:
109 %or = or <2 x i64> %B, %C
110 %nor = xor <2 x i64> %or, <i64 -1, i64 -1> ; Vector NOR operation
111 %res = select <2 x i1> %A, <2 x i64> %B, <2 x i64> %nor
112 ret <2 x i64> %res
113 }
114
115 ; Function to test ternary(A, B, nor(B,C)) for <16 x i8>
116 define <16 x i8> @ternary_A_B_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
117 ; CHECK-LABEL: ternary_A_B_nor_BC_16x8:
118 ; CHECK: # %bb.0: # %entry
119 ; CHECK-NEXT: xxspltib v5, 7
120 ; CHECK-NEXT: vslb v2, v2, v5
121 ; CHECK-NEXT: vsrab v2, v2, v5
122 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 131
123 ; CHECK-NEXT: blr
124 entry:
125 %or = or <16 x i8> %B, %C
126 %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
127 %res = select <16 x i1> %A, <16 x i8> %B, <16 x i8> %nor
128 ret <16 x i8> %res
129 }
130
131 ; Function to test ternary(A, B, nor(B,C)) for <8 x i16>
132 define <8 x i16> @ternary_A_B_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
133 ; CHECK-LABEL: ternary_A_B_nor_BC_8x16:
134 ; CHECK: # %bb.0: # %entry
135 ; CHECK-NEXT: xxspltiw v5, 983055
136 ; CHECK-NEXT: vslh v2, v2, v5
137 ; CHECK-NEXT: vsrah v2, v2, v5
138 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 131
139 ; CHECK-NEXT: blr
140 entry:
141 %or = or <8 x i16> %B, %C
142 %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
143 %res = select <8 x i1> %A, <8 x i16> %B, <8 x i16> %nor
144 ret <8 x i16> %res
145 }
146
147 ; Function to test ternary(A, C, nor(B,C)) for <4 x i32>
148 define <4 x i32> @ternary_A_C_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
149 ; CHECK-LABEL: ternary_A_C_nor_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, 133
155 ; CHECK-NEXT: blr
156 entry:
157 %or = or <4 x i32> %B, %C
158 %nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector NOR operation
159 %res = select <4 x i1> %A, <4 x i32> %C, <4 x i32> %nor
160 ret <4 x i32> %res
161 }
162
163 ; Function to test ternary(A, C, nor(B,C)) for <2 x i64>
164 define <2 x i64> @ternary_A_C_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
165 ; CHECK-LABEL: ternary_A_C_nor_BC_2x64:
166 ; CHECK: # %bb.0: # %entry
167 ; CHECK-NEXT: xxlxor v5, v5, v5
168 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
169 ; CHECK-NEXT: vsld v2, v2, v5
170 ; CHECK-NEXT: vsrad v2, v2, v5
171 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 133
172 ; CHECK-NEXT: blr
173 entry:
174 %or = or <2 x i64> %B, %C
175 %nor = xor <2 x i64> %or, <i64 -1, i64 -1> ; Vector NOR operation
176 %res = select <2 x i1> %A, <2 x i64> %C, <2 x i64> %nor
177 ret <2 x i64> %res
178 }
179
180 ; Function to test ternary(A, C, nor(B,C)) for <16 x i8>
181 define <16 x i8> @ternary_A_C_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
182 ; CHECK-LABEL: ternary_A_C_nor_BC_16x8:
183 ; CHECK: # %bb.0: # %entry
184 ; CHECK-NEXT: xxspltib v5, 7
185 ; CHECK-NEXT: vslb v2, v2, v5
186 ; CHECK-NEXT: vsrab v2, v2, v5
187 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 133
188 ; CHECK-NEXT: blr
189 entry:
190 %or = or <16 x i8> %B, %C
191 %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
192 %res = select <16 x i1> %A, <16 x i8> %C, <16 x i8> %nor
193 ret <16 x i8> %res
194 }
195
196 ; Function to test ternary(A, C, nor(B,C)) for <8 x i16>
197 define <8 x i16> @ternary_A_C_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
198 ; CHECK-LABEL: ternary_A_C_nor_BC_8x16:
199 ; CHECK: # %bb.0: # %entry
200 ; CHECK-NEXT: xxspltiw v5, 983055
201 ; CHECK-NEXT: vslh v2, v2, v5
202 ; CHECK-NEXT: vsrah v2, v2, v5
203 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 133
204 ; CHECK-NEXT: blr
205 entry:
206 %or = or <8 x i16> %B, %C
207 %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
208 %res = select <8 x i1> %A, <8 x i16> %C, <8 x i16> %nor
209 ret <8 x i16> %res
210 }
211
212 ; Function to test ternary(A, xor(B,C), nor(B,C)) for <4 x i32>
213 define <4 x i32> @ternary_A_xor_BC_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
214 ; CHECK-LABEL: ternary_A_xor_BC_nor_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, 134
220 ; CHECK-NEXT: blr
221 entry:
222 %xor = xor <4 x i32> %B, %C
223 %or = or <4 x i32> %B, %C
224 %nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector NOR operation
225 %res = select <4 x i1> %A, <4 x i32> %xor, <4 x i32> %nor
226 ret <4 x i32> %res
227 }
228
229 ; Function to test ternary(A, xor(B,C), nor(B,C)) for <2 x i64>
230 define <2 x i64> @ternary_A_xor_BC_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
231 ; CHECK-LABEL: ternary_A_xor_BC_nor_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, 134
238 ; CHECK-NEXT: blr
239 entry:
240 %xor = xor <2 x i64> %B, %C
241 %or = or <2 x i64> %B, %C
242 %nor = xor <2 x i64> %or, <i64 -1, i64 -1> ; Vector NOR operation
243 %res = select <2 x i1> %A, <2 x i64> %xor, <2 x i64> %nor
244 ret <2 x i64> %res
245 }
246
247 ; Function to test ternary(A, xor(B,C), nor(B,C)) for <16 x i8>
248 define <16 x i8> @ternary_A_xor_BC_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
249 ; CHECK-LABEL: ternary_A_xor_BC_nor_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, 134
255 ; CHECK-NEXT: blr
256 entry:
257 %xor = xor <16 x i8> %B, %C
258 %or = or <16 x i8> %B, %C
259 %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
260 %res = select <16 x i1> %A, <16 x i8> %xor, <16 x i8> %nor
261 ret <16 x i8> %res
262 }
263
264 ; Function to test ternary(A, xor(B,C), nor(B,C)) for <8 x i16>
265 define <8 x i16> @ternary_A_xor_BC_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
266 ; CHECK-LABEL: ternary_A_xor_BC_nor_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, 134
272 ; CHECK-NEXT: blr
273 entry:
274 %xor = xor <8 x i16> %B, %C
275 %or = or <8 x i16> %B, %C
276 %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
277 %res = select <8 x i1> %A, <8 x i16> %xor, <8 x i16> %nor
278 ret <8 x i16> %res
279 }
280
281 ; Function to test ternary(A, not(C), nor(B,C)) for <4 x i32>
282 define <4 x i32> @ternary_A_not_C_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
283 ; CHECK-LABEL: ternary_A_not_C_nor_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, 138
289 ; CHECK-NEXT: blr
290 entry:
291 %not = xor <4 x i32> %C, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector not operation
292 %or = or <4 x i32> %B, %C
293 %nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector NOR operation
294 %res = select <4 x i1> %A, <4 x i32> %not, <4 x i32> %nor
295 ret <4 x i32> %res
296 }
297
298 ; Function to test ternary(A, not(C), nor(B,C)) for <2 x i64>
299 define <2 x i64> @ternary_A_not_C_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
300 ; CHECK-LABEL: ternary_A_not_C_nor_BC_2x64:
301 ; CHECK: # %bb.0: # %entry
302 ; CHECK-NEXT: xxlxor v5, v5, v5
303 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
304 ; CHECK-NEXT: vsld v2, v2, v5
305 ; CHECK-NEXT: vsrad v2, v2, v5
306 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 138
307 ; CHECK-NEXT: blr
308 entry:
309 %not = xor <2 x i64> %C, <i64 -1, i64 -1> ; Vector not operation
310 %or = or <2 x i64> %B, %C
311 %nor = xor <2 x i64> %or, <i64 -1, i64 -1> ; Vector NOR operation
312 %res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %nor
313 ret <2 x i64> %res
314 }
315
316 ; Function to test ternary(A, not(C), nor(B,C)) for <16 x i8>
317 define <16 x i8> @ternary_A_not_C_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
318 ; CHECK-LABEL: ternary_A_not_C_nor_BC_16x8:
319 ; CHECK: # %bb.0: # %entry
320 ; CHECK-NEXT: xxspltib v5, 7
321 ; CHECK-NEXT: vslb v2, v2, v5
322 ; CHECK-NEXT: vsrab v2, v2, v5
323 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 138
324 ; CHECK-NEXT: blr
325 entry:
326 %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
327 %or = or <16 x i8> %B, %C
328 %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
329 %res = select <16 x i1> %A, <16 x i8> %not, <16 x i8> %nor
330 ret <16 x i8> %res
331 }
332
333 ; Function to test ternary(A, not(C), nor(B,C)) for <8 x i16>
334 define <8 x i16> @ternary_A_not_C_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
335 ; CHECK-LABEL: ternary_A_not_C_nor_BC_8x16:
336 ; CHECK: # %bb.0: # %entry
337 ; CHECK-NEXT: xxspltiw v5, 983055
338 ; CHECK-NEXT: vslh v2, v2, v5
339 ; CHECK-NEXT: vsrah v2, v2, v5
340 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 138
341 ; CHECK-NEXT: blr
342 entry:
343 %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
344 %or = or <8 x i16> %B, %C
345 %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
346 %res = select <8 x i1> %A, <8 x i16> %not, <8 x i16> %nor
347 ret <8 x i16> %res
348 }
349
350 ; Function to test ternary(A, not(B), nor(B,C)) for <4 x i32>
351 define <4 x i32> @ternary_A_not_B_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
352 ; CHECK-LABEL: ternary_A_not_B_nor_BC_4x32:
353 ; CHECK: # %bb.0: # %entry
354 ; CHECK-NEXT: xxleqv v5, v5, v5
355 ; CHECK-NEXT: vslw v2, v2, v5
356 ; CHECK-NEXT: vsraw v2, v2, v5
357 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 140
358 ; CHECK-NEXT: blr
359 entry:
360 %not = xor <4 x i32> %B, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector not operation
361 %or = or <4 x i32> %B, %C
362 %nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector NOR operation
363 %res = select <4 x i1> %A, <4 x i32> %not, <4 x i32> %nor
364 ret <4 x i32> %res
365 }
366
367 ; Function to test ternary(A, not(B), nor(B,C)) for <2 x i64>
368 define <2 x i64> @ternary_A_not_B_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
369 ; CHECK-LABEL: ternary_A_not_B_nor_BC_2x64:
370 ; CHECK: # %bb.0: # %entry
371 ; CHECK-NEXT: xxlxor v5, v5, v5
372 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
373 ; CHECK-NEXT: vsld v2, v2, v5
374 ; CHECK-NEXT: vsrad v2, v2, v5
375 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 140
376 ; CHECK-NEXT: blr
377 entry:
378 %not = xor <2 x i64> %B, <i64 -1, i64 -1> ; Vector not operation
379 %or = or <2 x i64> %B, %C
380 %nor = xor <2 x i64> %or, <i64 -1, i64 -1> ; Vector NOR operation
381 %res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %nor
382 ret <2 x i64> %res
383 }
384
385 ; Function to test ternary(A, not(B), nor(B,C)) for <16 x i8>
386 define <16 x i8> @ternary_A_not_B_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
387 ; CHECK-LABEL: ternary_A_not_B_nor_BC_16x8:
388 ; CHECK: # %bb.0: # %entry
389 ; CHECK-NEXT: xxspltib v5, 7
390 ; CHECK-NEXT: vslb v2, v2, v5
391 ; CHECK-NEXT: vsrab v2, v2, v5
392 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 140
393 ; CHECK-NEXT: blr
394 entry:
395 %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
396 %or = or <16 x i8> %B, %C
397 %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
398 %res = select <16 x i1> %A, <16 x i8> %not, <16 x i8> %nor
399 ret <16 x i8> %res
400 }
401
402 ; Function to test ternary(A, not(B), nor(B,C)) for <8 x i16>
403 define <8 x i16> @ternary_A_not_B_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
404 ; CHECK-LABEL: ternary_A_not_B_nor_BC_8x16:
405 ; CHECK: # %bb.0: # %entry
406 ; CHECK-NEXT: xxspltiw v5, 983055
407 ; CHECK-NEXT: vslh v2, v2, v5
408 ; CHECK-NEXT: vsrah v2, v2, v5
409 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 140
410 ; CHECK-NEXT: blr
411 entry:
412 %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
413 %or = or <8 x i16> %B, %C
414 %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
415 %res = select <8 x i1> %A, <8 x i16> %not, <8 x i16> %nor
416 ret <8 x i16> %res
417 }
418
419 ; Function to test ternary(A, nand(B,C), nor(B,C)) for <4 x i32>
420 define <4 x i32> @ternary_A_nand_BC_nor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
421 ; CHECK-LABEL: ternary_A_nand_BC_nor_BC_4x32:
422 ; CHECK: # %bb.0: # %entry
423 ; CHECK-NEXT: xxleqv v5, v5, v5
424 ; CHECK-NEXT: vslw v2, v2, v5
425 ; CHECK-NEXT: vsraw v2, v2, v5
426 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 142
427 ; CHECK-NEXT: blr
428 entry:
429 %and = and <4 x i32> %B, %C
430 %nand = xor <4 x i32> %and, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector nand operation
431 %or = or <4 x i32> %B, %C
432 %nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector NOR operation
433 %res = select <4 x i1> %A, <4 x i32> %nand, <4 x i32> %nor
434 ret <4 x i32> %res
435 }
436
437 ; Function to test ternary(A, nand(B,C), nor(B,C)) for <2 x i64>
438 define <2 x i64> @ternary_A_nand_BC_nor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
439 ; CHECK-LABEL: ternary_A_nand_BC_nor_BC_2x64:
440 ; CHECK: # %bb.0: # %entry
441 ; CHECK-NEXT: xxlxor v5, v5, v5
442 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
443 ; CHECK-NEXT: vsld v2, v2, v5
444 ; CHECK-NEXT: vsrad v2, v2, v5
445 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 142
446 ; CHECK-NEXT: blr
447 entry:
448 %and = and <2 x i64> %B, %C
449 %nand = xor <2 x i64> %and, <i64 -1, i64 -1> ; Vector nand operation
450 %or = or <2 x i64> %B, %C
451 %nor = xor <2 x i64> %or, <i64 -1, i64 -1> ; Vector NOR operation
452 %res = select <2 x i1> %A, <2 x i64> %nand, <2 x i64> %nor
453 ret <2 x i64> %res
454 }
455
456 ; Function to test ternary(A, nand(B,C), nor(B,C)) for <16 x i8>
457 define <16 x i8> @ternary_A_nand_BC_nor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
458 ; CHECK-LABEL: ternary_A_nand_BC_nor_BC_16x8:
459 ; CHECK: # %bb.0: # %entry
460 ; CHECK-NEXT: xxspltib v5, 7
461 ; CHECK-NEXT: vslb v2, v2, v5
462 ; CHECK-NEXT: vsrab v2, v2, v5
463 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 142
464 ; CHECK-NEXT: blr
465 entry:
466 %and = and <16 x i8> %B, %C
467 %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
468 %or = or <16 x i8> %B, %C
469 %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
470 %res = select <16 x i1> %A, <16 x i8> %nand, <16 x i8> %nor
471 ret <16 x i8> %res
472 }
473
474 ; Function to test ternary(A, nand(B,C), nor(B,C)) for <8 x i16>
475 define <8 x i16> @ternary_A_nand_BC_nor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
476 ; CHECK-LABEL: ternary_A_nand_BC_nor_BC_8x16:
477 ; CHECK: # %bb.0: # %entry
478 ; CHECK-NEXT: xxspltiw v5, 983055
479 ; CHECK-NEXT: vslh v2, v2, v5
480 ; CHECK-NEXT: vsrah v2, v2, v5
481 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 142
482 ; CHECK-NEXT: blr
483 entry:
484 %and = and <8 x i16> %B, %C
485 %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
486 %or = or <8 x i16> %B, %C
487 %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
488 %res = select <8 x i1> %A, <8 x i16> %nand, <8 x i16> %nor
489 ret <8 x i16> %res
490 }