aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/PowerPC/xxeval-vselect-x-c.ll
blob: f70f1d093f069535989020f4066804d7a170d3e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; Test file to verify the emission of Vector Selection instructions when ternary operators are used.

; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64le-unknown-unknown \
; RUN:   -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s

; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc-ibm-aix-xcoff \
; RUN:   -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s

; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64-ibm-aix-xcoff \
; RUN:   -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s

; Function to test ternary(A, and(B, C), C) for <4 x i32>
define <4 x i32> @ternary_A_and_BC_C_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
; CHECK-LABEL: ternary_A_and_BC_C_4x32:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxleqv v5, v5, v5
; CHECK-NEXT:    xxland vs0, v3, v4
; CHECK-NEXT:    vslw v2, v2, v5
; CHECK-NEXT:    vsraw v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %and = and <4 x i32> %B, %C
  %res = select <4 x i1> %A, <4 x i32> %and, <4 x i32> %C
  ret <4 x i32> %res
}

; Function to test ternary(A, and(B, C), C) for <2 x i64>
define <2 x i64> @ternary_A_and_BC_C_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
; CHECK-LABEL: ternary_A_and_BC_C_2x64:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxlxor v5, v5, v5
; CHECK-NEXT:    xxland vs0, v3, v4
; CHECK-NEXT:    xxsplti32dx v5, 1, 63
; CHECK-NEXT:    vsld v2, v2, v5
; CHECK-NEXT:    vsrad v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %and = and <2 x i64> %B, %C
  %res = select <2 x i1> %A, <2 x i64> %and, <2 x i64> %C
  ret <2 x i64> %res
}

; Function to test ternary(A, and(B, C), C) for <16 x i8>
define <16 x i8> @ternary_A_and_BC_C_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
; CHECK-LABEL: ternary_A_and_BC_C_16x8:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxspltib v5, 7
; CHECK-NEXT:    xxland vs0, v3, v4
; CHECK-NEXT:    vslb v2, v2, v5
; CHECK-NEXT:    vsrab v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %and = and <16 x i8> %B, %C
  %res = select <16 x i1> %A, <16 x i8> %and, <16 x i8> %C
  ret <16 x i8> %res
}

; Function to test ternary(A, and(B, C), C) for <8 x i16>
define <8 x i16> @ternary_A_and_BC_C_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
; CHECK-LABEL: ternary_A_and_BC_C_8x16:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxspltiw v5, 983055
; CHECK-NEXT:    xxland vs0, v3, v4
; CHECK-NEXT:    vslh v2, v2, v5
; CHECK-NEXT:    vsrah v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %and = and <8 x i16> %B, %C
  %res = select <8 x i1> %A, <8 x i16> %and, <8 x i16> %C
  ret <8 x i16> %res
}

; Function to test ternary(A, nor(B, C), C) for <4 x i32>
define <4 x i32> @ternary_A_nor_BC_C_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
; CHECK-LABEL: ternary_A_nor_BC_C_4x32:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxleqv v5, v5, v5
; CHECK-NEXT:    xxlnor vs0, v3, v4
; CHECK-NEXT:    vslw v2, v2, v5
; CHECK-NEXT:    vsraw v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %or = or <4 x i32> %B, %C
  %nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1>  ; Vector NOR operation
  %res = select <4 x i1> %A, <4 x i32> %nor, <4 x i32> %C
  ret <4 x i32> %res
}

; Function to test ternary(A, nor(B, C), C) for <2 x i64>
define <2 x i64> @ternary_A_nor_BC_C_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
; CHECK-LABEL: ternary_A_nor_BC_C_2x64:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxlxor v5, v5, v5
; CHECK-NEXT:    xxlnor vs0, v3, v4
; CHECK-NEXT:    xxsplti32dx v5, 1, 63
; CHECK-NEXT:    vsld v2, v2, v5
; CHECK-NEXT:    vsrad v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %or = or <2 x i64> %B, %C
  %nor = xor <2 x i64> %or, <i64 -1, i64 -1>  ; Vector NOR operation
  %res = select <2 x i1> %A, <2 x i64> %nor, <2 x i64> %C
  ret <2 x i64> %res
}

; Function to test ternary(A, nor(B, C), C) for <16 x i8>
define <16 x i8> @ternary_A_nor_BC_C_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
; CHECK-LABEL: ternary_A_nor_BC_C_16x8:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxspltib v5, 7
; CHECK-NEXT:    xxlnor vs0, v3, v4
; CHECK-NEXT:    vslb v2, v2, v5
; CHECK-NEXT:    vsrab v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %or = or <16 x i8> %B, %C
  %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
  %res = select <16 x i1> %A, <16 x i8> %nor, <16 x i8> %C
  ret <16 x i8> %res
}

; Function to test ternary(A, nor(B, C), C) for <8 x i16>
define <8 x i16> @ternary_A_nor_BC_C_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
; CHECK-LABEL: ternary_A_nor_BC_C_8x16:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxspltiw v5, 983055
; CHECK-NEXT:    xxlnor vs0, v3, v4
; CHECK-NEXT:    vslh v2, v2, v5
; CHECK-NEXT:    vsrah v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %or = or <8 x i16> %B, %C
  %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
  %res = select <8 x i1> %A, <8 x i16> %nor, <8 x i16> %C
  ret <8 x i16> %res
}

; Function to test ternary(A, eqv(B, C), C) for <4 x i32>
define <4 x i32> @ternary_A_eqv_BC_C_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
; CHECK-LABEL: ternary_A_eqv_BC_C_4x32:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxleqv v5, v5, v5
; CHECK-NEXT:    xxleqv vs0, v3, v4
; CHECK-NEXT:    vslw v2, v2, v5
; CHECK-NEXT:    vsraw v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %xor = xor <4 x i32> %B, %C
  %eqv = xor <4 x i32> %xor, <i32 -1, i32 -1, i32 -1, i32 -1>  ; Vector eqv operation
  %res = select <4 x i1> %A, <4 x i32> %eqv, <4 x i32> %C
  ret <4 x i32> %res
}

; Function to test ternary(A, eqv(B, C), C) for <2 x i64>
define <2 x i64> @ternary_A_eqv_BC_C_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
; CHECK-LABEL: ternary_A_eqv_BC_C_2x64:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxlxor v5, v5, v5
; CHECK-NEXT:    xxleqv vs0, v3, v4
; CHECK-NEXT:    xxsplti32dx v5, 1, 63
; CHECK-NEXT:    vsld v2, v2, v5
; CHECK-NEXT:    vsrad v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %xor = xor <2 x i64> %B, %C
  %eqv = xor <2 x i64> %xor, <i64 -1, i64 -1>  ; Vector eqv operation
  %res = select <2 x i1> %A, <2 x i64> %eqv, <2 x i64> %C
  ret <2 x i64> %res
}

; Function to test ternary(A, eqv(B, C), C) for <16 x i8>
define <16 x i8> @ternary_A_eqv_BC_C_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
; CHECK-LABEL: ternary_A_eqv_BC_C_16x8:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxspltib v5, 7
; CHECK-NEXT:    xxleqv vs0, v3, v4
; CHECK-NEXT:    vslb v2, v2, v5
; CHECK-NEXT:    vsrab v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %xor = xor <16 x i8> %B, %C
  %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
  %res = select <16 x i1> %A, <16 x i8> %eqv, <16 x i8> %C
  ret <16 x i8> %res
}

; Function to test ternary(A, eqv(B, C), C) for <8 x i16>
define <8 x i16> @ternary_A_eqv_BC_C_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
; CHECK-LABEL: ternary_A_eqv_BC_C_8x16:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxspltiw v5, 983055
; CHECK-NEXT:    xxleqv vs0, v3, v4
; CHECK-NEXT:    vslh v2, v2, v5
; CHECK-NEXT:    vsrah v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %xor = xor <8 x i16> %B, %C
  %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
  %res = select <8 x i1> %A, <8 x i16> %eqv, <8 x i16> %C
  ret <8 x i16> %res
}

; Function to test ternary(A, nand(B, C), C) for <4 x i32>
define <4 x i32> @ternary_A_nand_BC_C_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
; CHECK-LABEL: ternary_A_nand_BC_C_4x32:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxleqv v5, v5, v5
; CHECK-NEXT:    xxlnand vs0, v3, v4
; CHECK-NEXT:    vslw v2, v2, v5
; CHECK-NEXT:    vsraw v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %and = and <4 x i32> %B, %C
  %nand = xor <4 x i32> %and, <i32 -1, i32 -1, i32 -1, i32 -1>  ; Vector nand operation
  %res = select <4 x i1> %A, <4 x i32> %nand, <4 x i32> %C
  ret <4 x i32> %res
}

; Function to test ternary(A, nand(B, C), C) for <2 x i64>
define <2 x i64> @ternary_A_nand_BC_C_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) {
; CHECK-LABEL: ternary_A_nand_BC_C_2x64:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxlxor v5, v5, v5
; CHECK-NEXT:    xxlnand vs0, v3, v4
; CHECK-NEXT:    xxsplti32dx v5, 1, 63
; CHECK-NEXT:    vsld v2, v2, v5
; CHECK-NEXT:    vsrad v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %and = and <2 x i64> %B, %C
  %nand = xor <2 x i64> %and, <i64 -1, i64 -1>  ; Vector nand operation
  %res = select <2 x i1> %A, <2 x i64> %nand, <2 x i64> %C
  ret <2 x i64> %res
}

; Function to test ternary(A, nand(B, C), C) for <16 x i8>
define <16 x i8> @ternary_A_nand_BC_C_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) {
; CHECK-LABEL: ternary_A_nand_BC_C_16x8:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxspltib v5, 7
; CHECK-NEXT:    xxlnand vs0, v3, v4
; CHECK-NEXT:    vslb v2, v2, v5
; CHECK-NEXT:    vsrab v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %and = and <16 x i8> %B, %C
  %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
  %res = select <16 x i1> %A, <16 x i8> %nand, <16 x i8> %C
  ret <16 x i8> %res
}

; Function to test ternary(A, nand(B, C), C) for <8 x i16>
define <8 x i16> @ternary_A_nand_BC_C_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) {
; CHECK-LABEL: ternary_A_nand_BC_C_8x16:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xxspltiw v5, 983055
; CHECK-NEXT:    xxlnand vs0, v3, v4
; CHECK-NEXT:    vslh v2, v2, v5
; CHECK-NEXT:    vsrah v2, v2, v5
; CHECK-NEXT:    xxsel v2, v4, vs0, v2
; CHECK-NEXT:    blr
entry:
  %and = and <8 x i16> %B, %C
  %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
  %res = select <8 x i1> %A, <8 x i16> %nand, <8 x i16> %C
  ret <8 x i16> %res
}