Skip to content

Commit 46eeffc

Browse files
author
Tony Varghese
committed
[NFC] Add testcases for locking down the xxeval instruction support for ternary operators
1 parent e020fc1 commit 46eeffc

File tree

4 files changed

+672
-0
lines changed

4 files changed

+672
-0
lines changed
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
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+
}
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64le-unknown-unknown \
2+
; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s
3+
4+
; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc-ibm-aix-xcoff \
5+
; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s
6+
7+
; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64-ibm-aix-xcoff \
8+
; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s
9+
10+
; Function to test ternary(A, and(B, C), B) for <4 x i32>
11+
; CHECK-LABEL: ternary_A_and_BC_B_4x32
12+
; CHECK: xxspltiw v5, 31
13+
; CHECK-NEXT: xxland vs0, v3, v4
14+
; CHECK-NEXT: vslw v2, v2, v5
15+
; CHECK-NEXT: vsraw v2, v2, v5
16+
; CHECK-NEXT: xxsel v2, v3, vs0, v2
17+
; CHECK-NEXT: blr
18+
define dso_local <4 x i32> @ternary_A_and_BC_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) local_unnamed_addr #0 {
19+
entry:
20+
%and = and <4 x i32> %B, %C
21+
%res = select <4 x i1> %A, <4 x i32> %and, <4 x i32> %B
22+
ret <4 x i32> %res
23+
}
24+
25+
; Function to test ternary(A, and(B, C), B) for <2 x i64>
26+
; CHECK-LABEL: ternary_A_and_BC_B_2x64
27+
; CHECK: xxlxor v5, v5, v5
28+
; CHECK-NEXT: xxland vs0, v3, v4
29+
; CHECK-NEXT: xxsplti32dx v5, 1, 63
30+
; CHECK-NEXT: vsld v2, v2, v5
31+
; CHECK-NEXT: vsrad v2, v2, v5
32+
; CHECK-NEXT: xxsel v2, v3, vs0, v2
33+
; CHECK-NEXT: blr
34+
define dso_local <2 x i64> @ternary_A_and_BC_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) local_unnamed_addr #0 {
35+
entry:
36+
%and = and <2 x i64> %B, %C
37+
%res = select <2 x i1> %A, <2 x i64> %and, <2 x i64> %B
38+
ret <2 x i64> %res
39+
}
40+
41+
; Function to test ternary(A, nor(B, C), B) for <4 x i32>
42+
; CHECK-LABEL: ternary_A_nor_BC_B_4x32
43+
; CHECK: xxspltiw v5, 31
44+
; CHECK-NEXT: xxlnor vs0, v3, v4
45+
; CHECK-NEXT: vslw v2, v2, v5
46+
; CHECK-NEXT: vsraw v2, v2, v5
47+
; CHECK-NEXT: xxsel v2, v3, vs0, v2
48+
; CHECK-NEXT: blr
49+
define dso_local <4 x i32> @ternary_A_nor_BC_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) local_unnamed_addr #0 {
50+
entry:
51+
%or = or <4 x i32> %B, %C
52+
%nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector NOR operation
53+
%res = select <4 x i1> %A, <4 x i32> %nor, <4 x i32> %B
54+
ret <4 x i32> %res
55+
}
56+
57+
; Function to test ternary(A, nor(B, C), B) for <2 x i64>
58+
; CHECK-LABEL: ternary_A_nor_BC_B_2x64
59+
; CHECK: xxlxor v5, v5, v5
60+
; CHECK-NEXT: xxlnor vs0, v3, v4
61+
; CHECK-NEXT: xxsplti32dx v5, 1, 63
62+
; CHECK-NEXT: vsld v2, v2, v5
63+
; CHECK-NEXT: vsrad v2, v2, v5
64+
; CHECK-NEXT: xxsel v2, v3, vs0, v2
65+
; CHECK-NEXT: blr
66+
define dso_local <2 x i64> @ternary_A_nor_BC_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) local_unnamed_addr #0 {
67+
entry:
68+
%or = or <2 x i64> %B, %C
69+
%nor = xor <2 x i64> %or, <i64 -1, i64 -1> ; Vector NOR operation
70+
%res = select <2 x i1> %A, <2 x i64> %nor, <2 x i64> %B
71+
ret <2 x i64> %res
72+
}
73+
74+
; Function to test ternary(A, eqv(B, C), B) for <4 x i32>
75+
; CHECK-LABEL: ternary_A_eqv_BC_B_4x32
76+
; CHECK: xxspltiw v5, 31
77+
; CHECK-NEXT: xxleqv vs0, v3, v4
78+
; CHECK-NEXT: vslw v2, v2, v5
79+
; CHECK-NEXT: vsraw v2, v2, v5
80+
; CHECK-NEXT: xxsel v2, v3, vs0, v2
81+
; CHECK-NEXT: blr
82+
define dso_local <4 x i32> @ternary_A_eqv_BC_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) local_unnamed_addr #0 {
83+
entry:
84+
%xor = xor <4 x i32> %B, %C
85+
%eqv = xor <4 x i32> %xor, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector eqv operation
86+
%res = select <4 x i1> %A, <4 x i32> %eqv, <4 x i32> %B
87+
ret <4 x i32> %res
88+
}
89+
90+
; Function to test ternary(A, eqv(B, C), B) for <2 x i64>
91+
; CHECK-LABEL: ternary_A_eqv_BC_B_2x64
92+
; CHECK: xxlxor v5, v5, v5
93+
; CHECK-NEXT: xxleqv vs0, v3, v4
94+
; CHECK-NEXT: xxsplti32dx v5, 1, 63
95+
; CHECK-NEXT: vsld v2, v2, v5
96+
; CHECK-NEXT: vsrad v2, v2, v5
97+
; CHECK-NEXT: xxsel v2, v3, vs0, v2
98+
; CHECK-NEXT: blr
99+
define dso_local <2 x i64> @ternary_A_eqv_BC_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) local_unnamed_addr #0 {
100+
entry:
101+
%xor = xor <2 x i64> %B, %C
102+
%eqv = xor <2 x i64> %xor, <i64 -1, i64 -1> ; Vector eqv operation
103+
%res = select <2 x i1> %A, <2 x i64> %eqv, <2 x i64> %B
104+
ret <2 x i64> %res
105+
}
106+
107+
; Function to test ternary(A, not(C), B) for <4 x i32>
108+
; CHECK-LABEL: ternary_A_not_C_B_4x32
109+
; CHECK: xxspltiw v5, 31
110+
; CHECK-NEXT: xxlnor vs0, v4, v4
111+
; CHECK-NEXT: vslw v2, v2, v5
112+
; CHECK-NEXT: vsraw v2, v2, v5
113+
; CHECK-NEXT: xxsel v2, v3, vs0, v2
114+
; CHECK-NEXT: blr
115+
define dso_local <4 x i32> @ternary_A_not_C_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) local_unnamed_addr #0 {
116+
entry:
117+
%not = xor <4 x i32> %C, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector not operation
118+
%res = select <4 x i1> %A, <4 x i32> %not, <4 x i32> %B
119+
ret <4 x i32> %res
120+
}
121+
122+
; Function to test ternary(A, not(C), B) for <2 x i64>
123+
; CHECK-LABEL: ternary_A_not_C_B_2x64
124+
; CHECK: xxlxor v5, v5, v5
125+
; CHECK-NEXT: xxlnor vs0, v4, v4
126+
; CHECK-NEXT: xxsplti32dx v5, 1, 63
127+
; CHECK-NEXT: vsld v2, v2, v5
128+
; CHECK-NEXT: vsrad v2, v2, v5
129+
; CHECK-NEXT: xxsel v2, v3, vs0, v2
130+
; CHECK-NEXT: blr
131+
define dso_local <2 x i64> @ternary_A_not_C_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) local_unnamed_addr #0 {
132+
entry:
133+
%not = xor <2 x i64> %C, <i64 -1, i64 -1> ; Vector not operation
134+
%res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %B
135+
ret <2 x i64> %res
136+
}
137+
138+
; Function to test ternary(A, nand(B, C), B) for <4 x i32>
139+
; CHECK-LABEL: ternary_A_nand_BC_B_4x32
140+
; CHECK: xxspltiw v5, 31
141+
; CHECK-NEXT: xxlnand vs0, v3, v4
142+
; CHECK-NEXT: vslw v2, v2, v5
143+
; CHECK-NEXT: vsraw v2, v2, v5
144+
; CHECK-NEXT: xxsel v2, v3, vs0, v2
145+
; CHECK-NEXT: blr
146+
define dso_local <4 x i32> @ternary_A_nand_BC_B_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) local_unnamed_addr #0 {
147+
entry:
148+
%and = and <4 x i32> %B, %C
149+
%nand = xor <4 x i32> %and, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector nand operation
150+
%res = select <4 x i1> %A, <4 x i32> %nand, <4 x i32> %B
151+
ret <4 x i32> %res
152+
}
153+
154+
; Function to test ternary(A, nand(B, C), B) for <2 x i64>
155+
; CHECK-LABEL: ternary_A_nand_BC_B_2x64
156+
; CHECK: xxlxor v5, v5, v5
157+
; CHECK-NEXT: xxlnand vs0, v3, v4
158+
; CHECK-NEXT: xxsplti32dx v5, 1, 63
159+
; CHECK-NEXT: vsld v2, v2, v5
160+
; CHECK-NEXT: vsrad v2, v2, v5
161+
; CHECK-NEXT: xxsel v2, v3, vs0, v2
162+
; CHECK-NEXT: blr
163+
define dso_local <2 x i64> @ternary_A_nand_BC_B_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) local_unnamed_addr #0 {
164+
entry:
165+
%and = and <2 x i64> %B, %C
166+
%nand = xor <2 x i64> %and, <i64 -1, i64 -1> ; Vector nand operation
167+
%res = select <2 x i1> %A, <2 x i64> %nand, <2 x i64> %B
168+
ret <2 x i64> %res
169+
}

0 commit comments

Comments
 (0)