1
+ ; Test file to verify the emission of Vector selection instructions when ternary operators are used.
2
+
3
+ ; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64le-unknown-unknown \
4
+ ; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s
5
+
6
+ ; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc-ibm-aix-xcoff \
7
+ ; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s
8
+
9
+ ; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64-ibm-aix-xcoff \
10
+ ; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s
11
+
12
+ ; Function to test ternary(A, xor(B, C), and(B, C)) for <4 x i32>
13
+ ; CHECK-LABEL: ternary_A_xor_BC_and_BC_4x32
14
+ ; CHECK: xxspltiw v5, 31
15
+ ; CHECK-NEXT: xxlxor vs0, v3, v4
16
+ ; CHECK-NEXT: xxland vs1, v3, v4
17
+ ; CHECK-NEXT: vslw v2, v2, v5
18
+ ; CHECK-NEXT: vsraw v2, v2, v5
19
+ ; CHECK-NEXT: xxsel v2, vs1, vs0, v2
20
+ ; CHECK-NEXT: blr
21
+ define dso_local <4 x i32 > @ternary_A_xor_BC_and_BC_4x32 (<4 x i1 > %A , <4 x i32 > %B , <4 x i32 > %C ) local_unnamed_addr #0 {
22
+ entry:
23
+ %xor = xor <4 x i32 > %B , %C
24
+ %and = and <4 x i32 > %B , %C
25
+ %res = select <4 x i1 > %A , <4 x i32 > %xor , <4 x i32 > %and
26
+ ret <4 x i32 > %res
27
+ }
28
+
29
+ ; Function to test ternary(A, xor(B, C), and(B, C)) for <2 x i64>
30
+ ; CHECK-LABEL: ternary_A_xor_BC_and_BC_2x64
31
+ ; CHECK: xxlxor vs0, v3, v4
32
+ ; CHECK-NEXT: xxland vs1, v3, v4
33
+ ; CHECK-NEXT: xxsplti32dx v5, 1, 63
34
+ ; CHECK-NEXT: vsld v2, v2, v5
35
+ ; CHECK-NEXT: vsrad v2, v2, v5
36
+ ; CHECK-NEXT: xxsel v2, vs1, vs0, v2
37
+ ; CHECK-NEXT: blr
38
+ define dso_local <2 x i64 > @ternary_A_xor_BC_and_BC_2x64 (<2 x i1 > %A , <2 x i64 > %B , <2 x i64 > %C ) local_unnamed_addr #0 {
39
+ entry:
40
+ %xor = xor <2 x i64 > %B , %C
41
+ %and = and <2 x i64 > %B , %C
42
+ %res = select <2 x i1 > %A , <2 x i64 > %xor , <2 x i64 > %and
43
+ ret <2 x i64 > %res
44
+ }
45
+
46
+ ; Function to test ternary(A, nor(B, C), and(B, C)) for <4 x i32>
47
+ ; CHECK-LABEL: ternary_A_nor_BC_and_BC_4x32
48
+ ; CHECK: xxspltiw v5, 31
49
+ ; CHECK-NEXT: xxlnor vs0, v3, v4
50
+ ; CHECK-NEXT: xxland vs1, v3, v4
51
+ ; CHECK-NEXT: vslw v2, v2, v5
52
+ ; CHECK-NEXT: vsraw v2, v2, v5
53
+ ; CHECK-NEXT: xxsel v2, vs1, vs0, v2
54
+ ; CHECK-NEXT: blr
55
+ define dso_local <4 x i32 > @ternary_A_nor_BC_and_BC_4x32 (<4 x i1 > %A , <4 x i32 > %B , <4 x i32 > %C ) local_unnamed_addr #0 {
56
+ entry:
57
+ %or = or <4 x i32 > %B , %C
58
+ %nor = xor <4 x i32 > %or , <i32 -1 , i32 -1 , i32 -1 , i32 -1 > ; Vector NOR operation
59
+ %and = and <4 x i32 > %B , %C
60
+ %res = select <4 x i1 > %A , <4 x i32 > %nor , <4 x i32 > %and
61
+ ret <4 x i32 > %res
62
+ }
63
+
64
+ ; Function to test ternary(A, nor(B, C), and(B, C)) for <2 x i64>
65
+ ; CHECK-LABEL: ternary_A_nor_BC_and_BC_2x64
66
+ ; CHECK: xxlxor v5, v5, v5
67
+ ; CHECK-NEXT: xxlnor vs0, v3, v4
68
+ ; CHECK-NEXT: xxland vs1, v3, v4
69
+ ; CHECK-NEXT: xxsplti32dx v5, 1, 63
70
+ ; CHECK-NEXT: vsld v2, v2, v5
71
+ ; CHECK-NEXT: vsrad v2, v2, v5
72
+ ; CHECK-NEXT: xxsel v2, vs1, vs0, v2
73
+ ; CHECK-NEXT: blr
74
+ define dso_local <2 x i64 > @ternary_A_nor_BC_and_BC_2x64 (<2 x i1 > %A , <2 x i64 > %B , <2 x i64 > %C ) local_unnamed_addr #0 {
75
+ entry:
76
+ %or = or <2 x i64 > %B , %C
77
+ %nor = xor <2 x i64 > %or , <i64 -1 , i64 -1 > ; Vector NOR operation
78
+ %and = and <2 x i64 > %B , %C
79
+ %res = select <2 x i1 > %A , <2 x i64 > %nor , <2 x i64 > %and
80
+ ret <2 x i64 > %res
81
+ }
82
+
83
+ ; Function to test ternary(A, eqv(B, C), and(B, C)) for <4 x i32>
84
+ ; CHECK-LABEL: ternary_A_eqv_BC_and_BC_4x32
85
+ ; CHECK: xxspltiw v5, 31
86
+ ; CHECK-NEXT: xxleqv vs0, v3, v4
87
+ ; CHECK-NEXT: xxland vs1, v3, v4
88
+ ; CHECK-NEXT: vslw v2, v2, v5
89
+ ; CHECK-NEXT: vsraw v2, v2, v5
90
+ ; CHECK-NEXT: xxsel v2, vs1, vs0, v2
91
+ ; CHECK-NEXT: blr
92
+ define dso_local <4 x i32 > @ternary_A_eqv_BC_and_BC_4x32 (<4 x i1 > %A , <4 x i32 > %B , <4 x i32 > %C ) local_unnamed_addr #0 {
93
+ entry:
94
+ %xor = xor <4 x i32 > %B , %C
95
+ %eqv = xor <4 x i32 > %xor , <i32 -1 , i32 -1 , i32 -1 , i32 -1 > ; Vector eqv operation
96
+ %and = and <4 x i32 > %B , %C
97
+ %res = select <4 x i1 > %A , <4 x i32 > %eqv , <4 x i32 > %and
98
+ ret <4 x i32 > %res
99
+ }
100
+
101
+ ; Function to test ternary(A, eqv(B, C), and(B, C)) for <2 x i64>
102
+ ; CHECK-LABEL: ternary_A_eqv_BC_and_BC_2x64
103
+ ; CHECK: xxlxor v5, v5, v5
104
+ ; CHECK-NEXT: xxleqv vs0, v3, v4
105
+ ; CHECK-NEXT: xxland vs1, v3, v4
106
+ ; CHECK-NEXT: xxsplti32dx v5, 1, 63
107
+ ; CHECK-NEXT: vsld v2, v2, v5
108
+ ; CHECK-NEXT: vsrad v2, v2, v5
109
+ ; CHECK-NEXT: xxsel v2, vs1, vs0, v2
110
+ ; CHECK-NEXT: blr
111
+ define dso_local <2 x i64 > @ternary_A_eqv_BC_and_BC_2x64 (<2 x i1 > %A , <2 x i64 > %B , <2 x i64 > %C ) local_unnamed_addr #0 {
112
+ entry:
113
+ %xor = xor <2 x i64 > %B , %C
114
+ %eqv = xor <2 x i64 > %xor , <i64 -1 , i64 -1 > ; Vector eqv operation
115
+ %and = and <2 x i64 > %B , %C
116
+ %res = select <2 x i1 > %A , <2 x i64 > %eqv , <2 x i64 > %and
117
+ ret <2 x i64 > %res
118
+ }
119
+
120
+ ; Function to test ternary(A, not(C), and(B, C)) for <4 x i32>
121
+ ; CHECK-LABEL: ternary_A_not_C_and_BC_4x32
122
+ ; CHECK: xxspltiw v5, 31
123
+ ; CHECK-NEXT: xxlnor vs0, v4, v4
124
+ ; CHECK-NEXT: xxland vs1, v3, v4
125
+ ; CHECK-NEXT: vslw v2, v2, v5
126
+ ; CHECK-NEXT: vsraw v2, v2, v5
127
+ ; CHECK-NEXT: xxsel v2, vs1, vs0, v2
128
+ ; CHECK-NEXT: blr
129
+ define dso_local <4 x i32 > @ternary_A_not_C_and_BC_4x32 (<4 x i1 > %A , <4 x i32 > %B , <4 x i32 > %C ) local_unnamed_addr #0 {
130
+ entry:
131
+ %not = xor <4 x i32 > %C , <i32 -1 , i32 -1 , i32 -1 , i32 -1 > ; Vector not operation
132
+ %and = and <4 x i32 > %B , %C
133
+ %res = select <4 x i1 > %A , <4 x i32 > %not , <4 x i32 > %and
134
+ ret <4 x i32 > %res
135
+ }
136
+
137
+ ; Function to test ternary(A, not(C), and(B, C)) for <2 x i64>
138
+ ; CHECK-LABEL: ternary_A_not_C_and_BC_2x64
139
+ ; CHECK: xxlxor v5, v5, v5
140
+ ; CHECK-NEXT: xxlnor vs0, v4, v4
141
+ ; CHECK-NEXT: xxland vs1, v3, v4
142
+ ; CHECK-NEXT: xxsplti32dx v5, 1, 63
143
+ ; CHECK-NEXT: vsld v2, v2, v5
144
+ ; CHECK-NEXT: vsrad v2, v2, v5
145
+ ; CHECK-NEXT: xxsel v2, vs1, vs0, v2
146
+ ; CHECK-NEXT: blr
147
+ define dso_local <2 x i64 > @ternary_A_not_C_and_BC_2x64 (<2 x i1 > %A , <2 x i64 > %B , <2 x i64 > %C ) local_unnamed_addr #0 {
148
+ entry:
149
+ %not = xor <2 x i64 > %C , <i64 -1 , i64 -1 > ; Vector not operation
150
+ %and = and <2 x i64 > %B , %C
151
+ %res = select <2 x i1 > %A , <2 x i64 > %not , <2 x i64 > %and
152
+ ret <2 x i64 > %res
153
+ }
154
+
155
+ ; Function to test ternary(A, not(B), and(B, C)) for <4 x i32>
156
+ ; CHECK-LABEL: ternary_A_not_B_and_BC_4x32
157
+ ; CHECK: xxspltiw v5, 31
158
+ ; CHECK-NEXT: xxlnor vs0, v3, v3
159
+ ; CHECK-NEXT: xxland vs1, v3, v4
160
+ ; CHECK-NEXT: vslw v2, v2, v5
161
+ ; CHECK-NEXT: vsraw v2, v2, v5
162
+ ; CHECK-NEXT: xxsel v2, vs1, vs0, v2
163
+ ; CHECK-NEXT: blr
164
+ define dso_local <4 x i32 > @ternary_A_not_B_and_BC_4x32 (<4 x i1 > %A , <4 x i32 > %B , <4 x i32 > %C ) local_unnamed_addr #0 {
165
+ entry:
166
+ %not = xor <4 x i32 > %B , <i32 -1 , i32 -1 , i32 -1 , i32 -1 > ; Vector not operation
167
+ %and = and <4 x i32 > %B , %C
168
+ %res = select <4 x i1 > %A , <4 x i32 > %not , <4 x i32 > %and
169
+ ret <4 x i32 > %res
170
+ }
171
+
172
+ ; Function to test ternary(A, not(B), and(B, C)) for <2 x i64>
173
+ ; CHECK-LABEL: ternary_A_not_B_and_BC_2x64
174
+ ; CHECK: xxlxor v5, v5, v5
175
+ ; CHECK-NEXT: xxlnor vs0, v3, v3
176
+ ; CHECK-NEXT: xxland vs1, v3, v4
177
+ ; CHECK-NEXT: xxsplti32dx v5, 1, 63
178
+ ; CHECK-NEXT: vsld v2, v2, v5
179
+ ; CHECK-NEXT: vsrad v2, v2, v5
180
+ ; CHECK-NEXT: xxsel v2, vs1, vs0, v2
181
+ ; CHECK-NEXT: blr
182
+ define dso_local <2 x i64 > @ternary_A_not_B_and_BC_2x64 (<2 x i1 > %A , <2 x i64 > %B , <2 x i64 > %C ) local_unnamed_addr #0 {
183
+ entry:
184
+ %not = xor <2 x i64 > %B , <i64 -1 , i64 -1 > ; Vector not operation
185
+ %and = and <2 x i64 > %B , %C
186
+ %res = select <2 x i1 > %A , <2 x i64 > %not , <2 x i64 > %and
187
+ ret <2 x i64 > %res
188
+ }
0 commit comments