Skip to content

Commit 384b815

Browse files
[Hexagon] Use isNullConstant (NFC)
1 parent b95028e commit 384b815

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,15 +1028,11 @@ void HexagonDAGToDAGISel::ppSimplifyOrSelect0(std::vector<SDNode*> &&Nodes) {
10281028
if (I->getOpcode() != ISD::OR)
10291029
continue;
10301030

1031-
auto IsZero = [] (const SDValue &V) -> bool {
1032-
if (ConstantSDNode *SC = dyn_cast<ConstantSDNode>(V.getNode()))
1033-
return SC->isZero();
1034-
return false;
1035-
};
1036-
auto IsSelect0 = [IsZero] (const SDValue &Op) -> bool {
1031+
auto IsSelect0 = [](const SDValue &Op) -> bool {
10371032
if (Op.getOpcode() != ISD::SELECT)
10381033
return false;
1039-
return IsZero(Op.getOperand(1)) || IsZero(Op.getOperand(2));
1034+
return isNullConstant(Op.getOperand(1)) ||
1035+
isNullConstant(Op.getOperand(2));
10401036
};
10411037

10421038
SDValue N0 = I->getOperand(0), N1 = I->getOperand(1);
@@ -1050,11 +1046,11 @@ void HexagonDAGToDAGISel::ppSimplifyOrSelect0(std::vector<SDNode*> &&Nodes) {
10501046
SDValue SX = SOp.getOperand(1);
10511047
SDValue SY = SOp.getOperand(2);
10521048
SDLoc DLS = SOp;
1053-
if (IsZero(SY)) {
1049+
if (isNullConstant(SY)) {
10541050
SDValue NewOr = DAG.getNode(ISD::OR, DLS, VT, SX, VOp);
10551051
SDValue NewSel = DAG.getNode(ISD::SELECT, DLS, VT, SC, NewOr, VOp);
10561052
DAG.ReplaceAllUsesWith(I, NewSel.getNode());
1057-
} else if (IsZero(SX)) {
1053+
} else if (isNullConstant(SX)) {
10581054
SDValue NewOr = DAG.getNode(ISD::OR, DLS, VT, SY, VOp);
10591055
SDValue NewSel = DAG.getNode(ISD::SELECT, DLS, VT, SC, VOp, NewOr);
10601056
DAG.ReplaceAllUsesWith(I, NewSel.getNode());

llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2717,12 +2717,11 @@ HexagonTargetLowering::extractVectorPred(SDValue VecV, SDValue IdxV,
27172717
assert(VecWidth == 8 || VecWidth == 4 || VecWidth == 2);
27182718

27192719
// Check if this is an extract of the lowest bit.
2720-
if (auto *IdxN = dyn_cast<ConstantSDNode>(IdxV)) {
2720+
if (isNullConstant(IdxV) && ValTy.getSizeInBits() == 1) {
27212721
// Extracting the lowest bit is a no-op, but it changes the type,
27222722
// so it must be kept as an operation to avoid errors related to
27232723
// type mismatches.
2724-
if (IdxN->isZero() && ValTy.getSizeInBits() == 1)
2725-
return DAG.getNode(HexagonISD::TYPECAST, dl, MVT::i1, VecV);
2724+
return DAG.getNode(HexagonISD::TYPECAST, dl, MVT::i1, VecV);
27262725
}
27272726

27282727
// If the value extracted is a single bit, use tstbit.

llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,7 @@ HexagonTargetLowering::buildHvxVectorReg(ArrayRef<SDValue> Values,
829829
return DAG.getUNDEF(VecTy);
830830
if (IsSplat) {
831831
assert(SplatV.getNode());
832-
auto *IdxN = dyn_cast<ConstantSDNode>(SplatV.getNode());
833-
if (IdxN && IdxN->isZero())
832+
if (isNullConstant(SplatV))
834833
return getZero(dl, VecTy, DAG);
835834
MVT WordTy = MVT::getVectorVT(MVT::i32, HwLen/4);
836835
SDValue S = DAG.getNode(ISD::SPLAT_VECTOR, dl, WordTy, SplatV);

0 commit comments

Comments
 (0)