Skip to content

Commit ae1bb44

Browse files
author
Simon Moll
committed
[VE] v256.32|64 setcc isel and tests
Reviewed By: kaz7 Differential Revision: https://reviews.llvm.org/D119223
1 parent fd2bb51 commit ae1bb44

File tree

6 files changed

+1666
-0
lines changed

6 files changed

+1666
-0
lines changed

llvm/lib/Target/VE/VEISelLowering.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -2728,6 +2728,12 @@ SDValue VETargetLowering::lowerToVVP(SDValue Op, SelectionDAG &DAG) const {
27282728
auto OnFalse = Op->getOperand(2);
27292729
return CDAG.getNode(VVPOpcode, LegalVecVT, {OnTrue, OnFalse, Mask, AVL});
27302730
}
2731+
if (VVPOpcode == VEISD::VVP_SETCC) {
2732+
auto LHS = Op->getOperand(0);
2733+
auto RHS = Op->getOperand(1);
2734+
auto Pred = Op->getOperand(2);
2735+
return CDAG.getNode(VVPOpcode, LegalVecVT, {LHS, RHS, Pred, Mask, AVL});
2736+
}
27312737
llvm_unreachable("lowerToVVP called for unexpected SDNode.");
27322738
}
27332739

llvm/lib/Target/VE/VVPInstrInfo.td

+16
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ def SDTSelectVVP : SDTypeProfile<1, 4, [ // vp_select, vp_merge
4848
IsVLVT<4>
4949
]>;
5050

51+
// SetCC (lhs, rhs, cc, mask, vl)
52+
def SDTSetCCVVP : SDTypeProfile<1, 5, [ // vp_setcc
53+
SDTCisVec<0>,
54+
SDTCisVec<1>,
55+
SDTCisSameNumEltsAs<0, 1>,
56+
SDTCisSameAs<1, 2>,
57+
SDTCisVT<3, OtherVT>,
58+
SDTCisInt<4>,
59+
SDTCisSameNumEltsAs<0, 4>,
60+
IsVLVT<5>
61+
]>;
62+
63+
5164
// Binary operator commutative pattern.
5265
class vvp_commutative<SDNode RootOp> :
5366
PatFrags<
@@ -90,3 +103,6 @@ def vvp_fdiv : SDNode<"VEISD::VVP_FDIV", SDTFPBinOpVVP>;
90103
// } Binary Operators
91104

92105
def vvp_select : SDNode<"VEISD::VVP_SELECT", SDTSelectVVP>;
106+
107+
// setcc (lhs, rhs, cc, mask, vl)
108+
def vvp_setcc : SDNode<"VEISD::VVP_SETCC", SDTSetCCVVP>;

llvm/lib/Target/VE/VVPInstrPatternsVec.td

+27
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,30 @@ defm : Merge_mvv_ShortLong<vvp_select,
293293
defm : Merge_mvv_ShortLong<vvp_select,
294294
v256i64,
295295
v256i32, "VMRG">;
296+
297+
multiclass Set_CC<ValueType DataVT, string FmkBaseName, string CmpBaseName, SDPatternOperator CCMatcher, SDNodeXForm CCConv> {
298+
// Unmasked.
299+
def : Pat<(v256i1 (vvp_setcc
300+
DataVT:$LHS, DataVT:$RHS, CCMatcher:$cond, (v256i1 true_mask), i32:$vl)),
301+
(!cast<Instruction>(FmkBaseName#"vl")
302+
(CCConv $cond),
303+
(!cast<Instruction>(CmpBaseName#"vvl")
304+
$LHS, $RHS, $vl),
305+
$vl)>;
306+
// Masked.
307+
def : Pat<(v256i1 (vvp_setcc
308+
DataVT:$LHS, DataVT:$RHS, CCMatcher:$cond, v256i1:$vm, i32:$vl)),
309+
(!cast<Instruction>(FmkBaseName#"vml")
310+
(CCConv $cond),
311+
(!cast<Instruction>(CmpBaseName#"vvl")
312+
$LHS, $RHS, $vl),
313+
$vm, $vl)>;
314+
}
315+
316+
defm : Set_CC<v256i64,"VFMKL","VCMPUL",CCUIOp,icond2cc>;
317+
defm : Set_CC<v256i64,"VFMKL","VCMPSL",CCSIOp,icond2cc>;
318+
defm : Set_CC<v256f64,"VFMKL","VFCMPD",cond,fcond2cc>;
319+
320+
defm : Set_CC<v256i32,"VFMKW","VCMPUW",CCUIOp,icond2cc>;
321+
defm : Set_CC<v256i32,"VFMKW","VCMPSWZX",CCSIOp,icond2cc>;
322+
defm : Set_CC<v256f32,"VFMKS","VFCMPS",cond,fcond2cc>;

llvm/lib/Target/VE/VVPNodes.def

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ ADD_BINARY_VVP_OP_COMPACT(FSUB)
5959
ADD_BINARY_VVP_OP_COMPACT(FMUL)
6060
ADD_BINARY_VVP_OP_COMPACT(FDIV)
6161

62+
ADD_VVP_OP(VVP_SETCC, SETCC)
63+
6264
// Shuffles.
6365
ADD_VVP_OP(VVP_SELECT,VSELECT)
6466
HANDLE_VP_TO_VVP(VP_SELECT, VVP_SELECT)

0 commit comments

Comments
 (0)