Debian Codegraph @

llvm/test/CodeGen/PowerPC/xxeval-vselect-x-xor.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), xor(B, C)) for <4 x i32>
14 define <4 x i32> @ternary_A_and_BC_xor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
15 ; CHECK-LABEL: ternary_A_and_BC_xor_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, 97
21 ; CHECK-NEXT: blr
22 entry:
23 %and = and <4 x i32> %B, %C
24 %xor = xor <4 x i32> %B, %C
25 %res = select <4 x i1> %A, <4 x i32> %and, <4 x i32> %xor
26 ret <4 x i32> %res
27 }
28
29 ; Function to test ternary(A, and(B, C), xor(B, C)) for <2 x i64>
30 define <2 x i64> @ternary_A_and_BC_xor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
31 ; CHECK-LABEL: ternary_A_and_BC_xor_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, 97
38 ; CHECK-NEXT: blr
39 entry:
40 %and = and <2 x i64> %B, %C
41 %xor = xor <2 x i64> %B, %C
42 %res = select <2 x i1> %A, <2 x i64> %and, <2 x i64> %xor
43 ret <2 x i64> %res
44 }
45
46 ; Function to test ternary(A, and(B, C), xor(B, C)) for <16 x i8>
47 define <16 x i8> @ternary_A_and_BC_xor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
48 ; CHECK-LABEL: ternary_A_and_BC_xor_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, 97
54 ; CHECK-NEXT: blr
55 entry:
56 %and = and <16 x i8> %B, %C
57 %xor = xor <16 x i8> %B, %C
58 %res = select <16 x i1> %A, <16 x i8> %and, <16 x i8> %xor
59 ret <16 x i8> %res
60 }
61
62 ; Function to test ternary(A, and(B, C), xor(B, C)) for <8 x i16>
63 define <8 x i16> @ternary_A_and_BC_xor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
64 ; CHECK-LABEL: ternary_A_and_BC_xor_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, 97
70 ; CHECK-NEXT: blr
71 entry:
72 %and = and <8 x i16> %B, %C
73 %xor = xor <8 x i16> %B, %C
74 %res = select <8 x i1> %A, <8 x i16> %and, <8 x i16> %xor
75 ret <8 x i16> %res
76 }
77
78 ; Function to test ternary(A, B, xor(B, C)) for <4 x i32>
79 define <4 x i32> @ternary_A_B_xor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
80 ; CHECK-LABEL: ternary_A_B_xor_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, 99
86 ; CHECK-NEXT: blr
87 entry:
88 %xor = xor <4 x i32> %B, %C
89 %res = select <4 x i1> %A, <4 x i32> %B, <4 x i32> %xor
90 ret <4 x i32> %res
91 }
92
93 ; Function to test ternary(A, B, xor(B, C)) for <2 x i64>
94 define <2 x i64> @ternary_A_B_xor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
95 ; CHECK-LABEL: ternary_A_B_xor_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, 99
102 ; CHECK-NEXT: blr
103 entry:
104 %xor = xor <2 x i64> %B, %C
105 %res = select <2 x i1> %A, <2 x i64> %B, <2 x i64> %xor
106 ret <2 x i64> %res
107 }
108
109 ; Function to test ternary(A, B, xor(B, C)) for <16 x i8>
110 define <16 x i8> @ternary_A_B_xor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
111 ; CHECK-LABEL: ternary_A_B_xor_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, 99
117 ; CHECK-NEXT: blr
118 entry:
119 %xor = xor <16 x i8> %B, %C
120 %res = select <16 x i1> %A, <16 x i8> %B, <16 x i8> %xor
121 ret <16 x i8> %res
122 }
123
124 ; Function to test ternary(A, B, xor(B, C)) for <8 x i16>
125 define <8 x i16> @ternary_A_B_xor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
126 ; CHECK-LABEL: ternary_A_B_xor_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, 99
132 ; CHECK-NEXT: blr
133 entry:
134 %xor = xor <8 x i16> %B, %C
135 %res = select <8 x i1> %A, <8 x i16> %B, <8 x i16> %xor
136 ret <8 x i16> %res
137 }
138
139 ; Function to test ternary(A, C, xor(B, C)) for <4 x i32>
140 define <4 x i32> @ternary_A_C_xor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
141 ; CHECK-LABEL: ternary_A_C_xor_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, 101
147 ; CHECK-NEXT: blr
148 entry:
149 %xor = xor <4 x i32> %B, %C
150 %res = select <4 x i1> %A, <4 x i32> %C, <4 x i32> %xor
151 ret <4 x i32> %res
152 }
153
154 ; Function to test ternary(A, C, xor(B, C)) for <2 x i64>
155 define <2 x i64> @ternary_A_C_xor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
156 ; CHECK-LABEL: ternary_A_C_xor_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, 101
163 ; CHECK-NEXT: blr
164 entry:
165 %xor = xor <2 x i64> %B, %C
166 %res = select <2 x i1> %A, <2 x i64> %C, <2 x i64> %xor
167 ret <2 x i64> %res
168 }
169
170 ; Function to test ternary(A, C, xor(B, C)) for <16 x i8>
171 define <16 x i8> @ternary_A_C_xor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
172 ; CHECK-LABEL: ternary_A_C_xor_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, 101
178 ; CHECK-NEXT: blr
179 entry:
180 %xor = xor <16 x i8> %B, %C
181 %res = select <16 x i1> %A, <16 x i8> %C, <16 x i8> %xor
182 ret <16 x i8> %res
183 }
184
185 ; Function to test ternary(A, C, xor(B, C)) for <8 x i16>
186 define <8 x i16> @ternary_A_C_xor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
187 ; CHECK-LABEL: ternary_A_C_xor_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, 101
193 ; CHECK-NEXT: blr
194 entry:
195 %xor = xor <8 x i16> %B, %C
196 %res = select <8 x i1> %A, <8 x i16> %C, <8 x i16> %xor
197 ret <8 x i16> %res
198 }
199
200 ; Function to test ternary(A, or(B, C), xor(B, C)) for <4 x i32>
201 define <4 x i32> @ternary_A_or_BC_xor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
202 ; CHECK-LABEL: ternary_A_or_BC_xor_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, 103
208 ; CHECK-NEXT: blr
209 entry:
210 %or = or <4 x i32> %B, %C
211 %xor = xor <4 x i32> %B, %C
212 %res = select <4 x i1> %A, <4 x i32> %or, <4 x i32> %xor
213 ret <4 x i32> %res
214 }
215
216 ; Function to test ternary(A, or(B, C), xor(B, C)) for <2 x i64>
217 define <2 x i64> @ternary_A_or_BC_xor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
218 ; CHECK-LABEL: ternary_A_or_BC_xor_BC_2x64:
219 ; CHECK: # %bb.0: # %entry
220 ; CHECK-NEXT: xxlxor v5, v5, v5
221 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
222 ; CHECK-NEXT: vsld v2, v2, v5
223 ; CHECK-NEXT: vsrad v2, v2, v5
224 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 103
225 ; CHECK-NEXT: blr
226 entry:
227 %or = or <2 x i64> %B, %C
228 %xor = xor <2 x i64> %B, %C
229 %res = select <2 x i1> %A, <2 x i64> %or, <2 x i64> %xor
230 ret <2 x i64> %res
231 }
232
233 ; Function to test ternary(A, or(B, C), xor(B, C)) for <16 x i8>
234 define <16 x i8> @ternary_A_or_BC_xor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
235 ; CHECK-LABEL: ternary_A_or_BC_xor_BC_16x8:
236 ; CHECK: # %bb.0: # %entry
237 ; CHECK-NEXT: xxspltib v5, 7
238 ; CHECK-NEXT: vslb v2, v2, v5
239 ; CHECK-NEXT: vsrab v2, v2, v5
240 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 103
241 ; CHECK-NEXT: blr
242 entry:
243 %or = or <16 x i8> %B, %C
244 %xor = xor <16 x i8> %B, %C
245 %res = select <16 x i1> %A, <16 x i8> %or, <16 x i8> %xor
246 ret <16 x i8> %res
247 }
248
249 ; Function to test ternary(A, or(B, C), xor(B, C)) for <8 x i16>
250 define <8 x i16> @ternary_A_or_BC_xor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
251 ; CHECK-LABEL: ternary_A_or_BC_xor_BC_8x16:
252 ; CHECK: # %bb.0: # %entry
253 ; CHECK-NEXT: xxspltiw v5, 983055
254 ; CHECK-NEXT: vslh v2, v2, v5
255 ; CHECK-NEXT: vsrah v2, v2, v5
256 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 103
257 ; CHECK-NEXT: blr
258 entry:
259 %or = or <8 x i16> %B, %C
260 %xor = xor <8 x i16> %B, %C
261 %res = select <8 x i1> %A, <8 x i16> %or, <8 x i16> %xor
262 ret <8 x i16> %res
263 }
264
265 ; Function to test ternary(A, nor(B, C), xor(B, C)) for <4 x i32>
266 define <4 x i32> @ternary_A_nor_BC_xor_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
267 ; CHECK-LABEL: ternary_A_nor_BC_xor_BC_4x32:
268 ; CHECK: # %bb.0: # %entry
269 ; CHECK-NEXT: xxleqv v5, v5, v5
270 ; CHECK-NEXT: vslw v2, v2, v5
271 ; CHECK-NEXT: vsraw v2, v2, v5
272 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 104
273 ; CHECK-NEXT: blr
274 entry:
275 %or = or <4 x i32> %B, %C
276 %nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1> ; vector nor operation
277 %xor = xor <4 x i32> %B, %C
278 %res = select <4 x i1> %A, <4 x i32> %nor, <4 x i32> %xor
279 ret <4 x i32> %res
280 }
281
282 ; Function to test ternary(A, nor(B, C), xor(B, C)) for <2 x i64>
283 define <2 x i64> @ternary_A_nor_BC_xor_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
284 ; CHECK-LABEL: ternary_A_nor_BC_xor_BC_2x64:
285 ; CHECK: # %bb.0: # %entry
286 ; CHECK-NEXT: xxlxor v5, v5, v5
287 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
288 ; CHECK-NEXT: vsld v2, v2, v5
289 ; CHECK-NEXT: vsrad v2, v2, v5
290 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 104
291 ; CHECK-NEXT: blr
292 entry:
293 %or = or <2 x i64> %B, %C
294 %nor = xor <2 x i64> %or, <i64 -1, i64 -1> ; vector nor operation
295 %xor = xor <2 x i64> %B, %C
296 %res = select <2 x i1> %A, <2 x i64> %nor, <2 x i64> %xor
297 ret <2 x i64> %res
298 }
299
300 ; Function to test ternary(A, nor(B, C), xor(B, C)) for <16 x i8>
301 define <16 x i8> @ternary_A_nor_BC_xor_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
302 ; CHECK-LABEL: ternary_A_nor_BC_xor_BC_16x8:
303 ; CHECK: # %bb.0: # %entry
304 ; CHECK-NEXT: xxspltib v5, 7
305 ; CHECK-NEXT: vslb v2, v2, v5
306 ; CHECK-NEXT: vsrab v2, v2, v5
307 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 104
308 ; CHECK-NEXT: blr
309 entry:
310 %or = or <16 x i8> %B, %C
311 %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
312 %xor = xor <16 x i8> %B, %C
313 %res = select <16 x i1> %A, <16 x i8> %nor, <16 x i8> %xor
314 ret <16 x i8> %res
315 }
316
317 ; Function to test ternary(A, nor(B, C), xor(B, C)) for <8 x i16>
318 define <8 x i16> @ternary_A_nor_BC_xor_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
319 ; CHECK-LABEL: ternary_A_nor_BC_xor_BC_8x16:
320 ; CHECK: # %bb.0: # %entry
321 ; CHECK-NEXT: xxspltiw v5, 983055
322 ; CHECK-NEXT: vslh v2, v2, v5
323 ; CHECK-NEXT: vsrah v2, v2, v5
324 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 104
325 ; CHECK-NEXT: blr
326 entry:
327 %or = or <8 x i16> %B, %C
328 %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
329 %xor = xor <8 x i16> %B, %C
330 %res = select <8 x i1> %A, <8 x i16> %nor, <8 x i16> %xor
331 ret <8 x i16> %res
332 }