Debian Codegraph @

llvm/test/CodeGen/PowerPC/xxeval-vselect-x-b.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 Evaluation 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), B) for <4 x i32>
14 define <4 x i32> @ternary_A_and_BC_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
15 ; CHECK-LABEL: ternary_A_and_BC_B_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, 49
21 ; CHECK-NEXT: blr
22 entry:
23 %and = and <4 x i32> %B, %C
24 %res = select <4 x i1> %A, <4 x i32> %and, <4 x i32> %B
25 ret <4 x i32> %res
26 }
27
28 ; Function to test ternary(A, and(B, C), B) for <2 x i64>
29 define <2 x i64> @ternary_A_and_BC_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
30 ; CHECK-LABEL: ternary_A_and_BC_B_2x64:
31 ; CHECK: # %bb.0: # %entry
32 ; CHECK-NEXT: xxlxor v5, v5, v5
33 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
34 ; CHECK-NEXT: vsld v2, v2, v5
35 ; CHECK-NEXT: vsrad v2, v2, v5
36 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 49
37 ; CHECK-NEXT: blr
38 entry:
39 %and = and <2 x i64> %B, %C
40 %res = select <2 x i1> %A, <2 x i64> %and, <2 x i64> %B
41 ret <2 x i64> %res
42 }
43
44 ; Function to test ternary(A, and(B, C), B) for <16 x i8>
45 define <16 x i8> @ternary_A_and_BC_B_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
46 ; CHECK-LABEL: ternary_A_and_BC_B_16x8:
47 ; CHECK: # %bb.0: # %entry
48 ; CHECK-NEXT: xxspltib v5, 7
49 ; CHECK-NEXT: vslb v2, v2, v5
50 ; CHECK-NEXT: vsrab v2, v2, v5
51 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 49
52 ; CHECK-NEXT: blr
53 entry:
54 %and = and <16 x i8> %B, %C
55 %res = select <16 x i1> %A, <16 x i8> %and, <16 x i8> %B
56 ret <16 x i8> %res
57 }
58
59 ; Function to test ternary(A, and(B, C), B) for <8 x i16>
60 define <8 x i16> @ternary_A_and_BC_B_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
61 ; CHECK-LABEL: ternary_A_and_BC_B_8x16:
62 ; CHECK: # %bb.0: # %entry
63 ; CHECK-NEXT: xxspltiw v5, 983055
64 ; CHECK-NEXT: vslh v2, v2, v5
65 ; CHECK-NEXT: vsrah v2, v2, v5
66 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 49
67 ; CHECK-NEXT: blr
68 entry:
69 %and = and <8 x i16> %B, %C
70 %res = select <8 x i1> %A, <8 x i16> %and, <8 x i16> %B
71 ret <8 x i16> %res
72 }
73
74 ; Function to test ternary(A, nor(B, C), B) for <4 x i32>
75 define <4 x i32> @ternary_A_nor_BC_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
76 ; CHECK-LABEL: ternary_A_nor_BC_B_4x32:
77 ; CHECK: # %bb.0: # %entry
78 ; CHECK-NEXT: xxleqv v5, v5, v5
79 ; CHECK-NEXT: vslw v2, v2, v5
80 ; CHECK-NEXT: vsraw v2, v2, v5
81 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 56
82 ; CHECK-NEXT: blr
83 entry:
84 %or = or <4 x i32> %B, %C
85 %nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector NOR operation
86 %res = select <4 x i1> %A, <4 x i32> %nor, <4 x i32> %B
87 ret <4 x i32> %res
88 }
89
90 ; Function to test ternary(A, nor(B, C), B) for <2 x i64>
91 define <2 x i64> @ternary_A_nor_BC_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
92 ; CHECK-LABEL: ternary_A_nor_BC_B_2x64:
93 ; CHECK: # %bb.0: # %entry
94 ; CHECK-NEXT: xxlxor v5, v5, v5
95 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
96 ; CHECK-NEXT: vsld v2, v2, v5
97 ; CHECK-NEXT: vsrad v2, v2, v5
98 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 56
99 ; CHECK-NEXT: blr
100 entry:
101 %or = or <2 x i64> %B, %C
102 %nor = xor <2 x i64> %or, <i64 -1, i64 -1> ; Vector NOR operation
103 %res = select <2 x i1> %A, <2 x i64> %nor, <2 x i64> %B
104 ret <2 x i64> %res
105 }
106
107 ; Function to test ternary(A, nor(B, C), B) for <16 x i8>
108 define <16 x i8> @ternary_A_nor_BC_B_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
109 ; CHECK-LABEL: ternary_A_nor_BC_B_16x8:
110 ; CHECK: # %bb.0: # %entry
111 ; CHECK-NEXT: xxspltib v5, 7
112 ; CHECK-NEXT: vslb v2, v2, v5
113 ; CHECK-NEXT: vsrab v2, v2, v5
114 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 56
115 ; CHECK-NEXT: blr
116 entry:
117 %or = or <16 x i8> %B, %C
118 %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
119 %res = select <16 x i1> %A, <16 x i8> %nor, <16 x i8> %B
120 ret <16 x i8> %res
121 }
122
123 ; Function to test ternary(A, nor(B, C), B) for <8 x i16>
124 define <8 x i16> @ternary_A_nor_BC_B_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
125 ; CHECK-LABEL: ternary_A_nor_BC_B_8x16:
126 ; CHECK: # %bb.0: # %entry
127 ; CHECK-NEXT: xxspltiw v5, 983055
128 ; CHECK-NEXT: vslh v2, v2, v5
129 ; CHECK-NEXT: vsrah v2, v2, v5
130 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 56
131 ; CHECK-NEXT: blr
132 entry:
133 %or = or <8 x i16> %B, %C
134 %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
135 %res = select <8 x i1> %A, <8 x i16> %nor, <8 x i16> %B
136 ret <8 x i16> %res
137 }
138
139 ; Function to test ternary(A, eqv(B, C), B) for <4 x i32>
140 define <4 x i32> @ternary_A_eqv_BC_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
141 ; CHECK-LABEL: ternary_A_eqv_BC_B_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, 57
147 ; CHECK-NEXT: blr
148 entry:
149 %xor = xor <4 x i32> %B, %C
150 %eqv = xor <4 x i32> %xor, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector eqv operation
151 %res = select <4 x i1> %A, <4 x i32> %eqv, <4 x i32> %B
152 ret <4 x i32> %res
153 }
154
155 ; Function to test ternary(A, eqv(B, C), B) for <2 x i64>
156 define <2 x i64> @ternary_A_eqv_BC_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
157 ; CHECK-LABEL: ternary_A_eqv_BC_B_2x64:
158 ; CHECK: # %bb.0: # %entry
159 ; CHECK-NEXT: xxlxor v5, v5, v5
160 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
161 ; CHECK-NEXT: vsld v2, v2, v5
162 ; CHECK-NEXT: vsrad v2, v2, v5
163 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 57
164 ; CHECK-NEXT: blr
165 entry:
166 %xor = xor <2 x i64> %B, %C
167 %eqv = xor <2 x i64> %xor, <i64 -1, i64 -1> ; Vector eqv operation
168 %res = select <2 x i1> %A, <2 x i64> %eqv, <2 x i64> %B
169 ret <2 x i64> %res
170 }
171
172 ; Function to test ternary(A, eqv(B, C), B) for <16 x i8>
173 define <16 x i8> @ternary_A_eqv_BC_B_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
174 ; CHECK-LABEL: ternary_A_eqv_BC_B_16x8:
175 ; CHECK: # %bb.0: # %entry
176 ; CHECK-NEXT: xxspltib v5, 7
177 ; CHECK-NEXT: vslb v2, v2, v5
178 ; CHECK-NEXT: vsrab v2, v2, v5
179 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 57
180 ; CHECK-NEXT: blr
181 entry:
182 %xor = xor <16 x i8> %B, %C
183 %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
184 %res = select <16 x i1> %A, <16 x i8> %eqv, <16 x i8> %B
185 ret <16 x i8> %res
186 }
187
188 ; Function to test ternary(A, eqv(B, C), B) for <8 x i16>
189 define <8 x i16> @ternary_A_eqv_BC_B_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
190 ; CHECK-LABEL: ternary_A_eqv_BC_B_8x16:
191 ; CHECK: # %bb.0: # %entry
192 ; CHECK-NEXT: xxspltiw v5, 983055
193 ; CHECK-NEXT: vslh v2, v2, v5
194 ; CHECK-NEXT: vsrah v2, v2, v5
195 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 57
196 ; CHECK-NEXT: blr
197 entry:
198 %xor = xor <8 x i16> %B, %C
199 %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
200 %res = select <8 x i1> %A, <8 x i16> %eqv, <8 x i16> %B
201 ret <8 x i16> %res
202 }
203
204 ; Function to test ternary(A, nand(B, C), B) for <4 x i32>
205 define <4 x i32> @ternary_A_nand_BC_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
206 ; CHECK-LABEL: ternary_A_nand_BC_B_4x32:
207 ; CHECK: # %bb.0: # %entry
208 ; CHECK-NEXT: xxleqv v5, v5, v5
209 ; CHECK-NEXT: vslw v2, v2, v5
210 ; CHECK-NEXT: vsraw v2, v2, v5
211 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 62
212 ; CHECK-NEXT: blr
213 entry:
214 %and = and <4 x i32> %B, %C
215 %nand = xor <4 x i32> %and, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector nand operation
216 %res = select <4 x i1> %A, <4 x i32> %nand, <4 x i32> %B
217 ret <4 x i32> %res
218 }
219
220 ; Function to test ternary(A, nand(B, C), B) for <2 x i64>
221 define <2 x i64> @ternary_A_nand_BC_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
222 ; CHECK-LABEL: ternary_A_nand_BC_B_2x64:
223 ; CHECK: # %bb.0: # %entry
224 ; CHECK-NEXT: xxlxor v5, v5, v5
225 ; CHECK-NEXT: xxsplti32dx v5, 1, 63
226 ; CHECK-NEXT: vsld v2, v2, v5
227 ; CHECK-NEXT: vsrad v2, v2, v5
228 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 62
229 ; CHECK-NEXT: blr
230 entry:
231 %and = and <2 x i64> %B, %C
232 %nand = xor <2 x i64> %and, <i64 -1, i64 -1> ; Vector nand operation
233 %res = select <2 x i1> %A, <2 x i64> %nand, <2 x i64> %B
234 ret <2 x i64> %res
235 }
236
237 ; Function to test ternary(A, nand(B, C), B) for <16 x i8>
238 define <16 x i8> @ternary_A_nand_BC_B_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
239 ; CHECK-LABEL: ternary_A_nand_BC_B_16x8:
240 ; CHECK: # %bb.0: # %entry
241 ; CHECK-NEXT: xxspltib v5, 7
242 ; CHECK-NEXT: vslb v2, v2, v5
243 ; CHECK-NEXT: vsrab v2, v2, v5
244 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 62
245 ; CHECK-NEXT: blr
246 entry:
247 %and = and <16 x i8> %B, %C
248 %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
249 %res = select <16 x i1> %A, <16 x i8> %nand, <16 x i8> %B
250 ret <16 x i8> %res
251 }
252
253 ; Function to test ternary(A, nand(B, C), B) for <8 x i16>
254 define <8 x i16> @ternary_A_nand_BC_B_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
255 ; CHECK-LABEL: ternary_A_nand_BC_B_8x16:
256 ; CHECK: # %bb.0: # %entry
257 ; CHECK-NEXT: xxspltiw v5, 983055
258 ; CHECK-NEXT: vslh v2, v2, v5
259 ; CHECK-NEXT: vsrah v2, v2, v5
260 ; CHECK-NEXT: xxeval v2, v2, v3, v4, 62
261 ; CHECK-NEXT: blr
262 entry:
263 %and = and <8 x i16> %B, %C
264 %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
265 %res = select <8 x i1> %A, <8 x i16> %nand, <8 x i16> %B
266 ret <8 x i16> %res
267 }