[llvm] 384b815 - [Hexagon] Use isNullConstant (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 2 12:12:24 PDT 2023
Author: Kazu Hirata
Date: 2023-09-02T12:12:14-07:00
New Revision: 384b81539e7c8254e968bbb1f9b875fc9cd669a1
URL: https://github.com/llvm/llvm-project/commit/384b81539e7c8254e968bbb1f9b875fc9cd669a1
DIFF: https://github.com/llvm/llvm-project/commit/384b81539e7c8254e968bbb1f9b875fc9cd669a1.diff
LOG: [Hexagon] Use isNullConstant (NFC)
Added:
Modified:
llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
index 5aad71a0a1c97c..e1db9f1f04f4dc 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
@@ -1028,15 +1028,11 @@ void HexagonDAGToDAGISel::ppSimplifyOrSelect0(std::vector<SDNode*> &&Nodes) {
if (I->getOpcode() != ISD::OR)
continue;
- auto IsZero = [] (const SDValue &V) -> bool {
- if (ConstantSDNode *SC = dyn_cast<ConstantSDNode>(V.getNode()))
- return SC->isZero();
- return false;
- };
- auto IsSelect0 = [IsZero] (const SDValue &Op) -> bool {
+ auto IsSelect0 = [](const SDValue &Op) -> bool {
if (Op.getOpcode() != ISD::SELECT)
return false;
- return IsZero(Op.getOperand(1)) || IsZero(Op.getOperand(2));
+ return isNullConstant(Op.getOperand(1)) ||
+ isNullConstant(Op.getOperand(2));
};
SDValue N0 = I->getOperand(0), N1 = I->getOperand(1);
@@ -1050,11 +1046,11 @@ void HexagonDAGToDAGISel::ppSimplifyOrSelect0(std::vector<SDNode*> &&Nodes) {
SDValue SX = SOp.getOperand(1);
SDValue SY = SOp.getOperand(2);
SDLoc DLS = SOp;
- if (IsZero(SY)) {
+ if (isNullConstant(SY)) {
SDValue NewOr = DAG.getNode(ISD::OR, DLS, VT, SX, VOp);
SDValue NewSel = DAG.getNode(ISD::SELECT, DLS, VT, SC, NewOr, VOp);
DAG.ReplaceAllUsesWith(I, NewSel.getNode());
- } else if (IsZero(SX)) {
+ } else if (isNullConstant(SX)) {
SDValue NewOr = DAG.getNode(ISD::OR, DLS, VT, SY, VOp);
SDValue NewSel = DAG.getNode(ISD::SELECT, DLS, VT, SC, VOp, NewOr);
DAG.ReplaceAllUsesWith(I, NewSel.getNode());
diff --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
index 695bc7d4e2f7d8..75a33937059118 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -2717,12 +2717,11 @@ HexagonTargetLowering::extractVectorPred(SDValue VecV, SDValue IdxV,
assert(VecWidth == 8 || VecWidth == 4 || VecWidth == 2);
// Check if this is an extract of the lowest bit.
- if (auto *IdxN = dyn_cast<ConstantSDNode>(IdxV)) {
+ if (isNullConstant(IdxV) && ValTy.getSizeInBits() == 1) {
// Extracting the lowest bit is a no-op, but it changes the type,
// so it must be kept as an operation to avoid errors related to
// type mismatches.
- if (IdxN->isZero() && ValTy.getSizeInBits() == 1)
- return DAG.getNode(HexagonISD::TYPECAST, dl, MVT::i1, VecV);
+ return DAG.getNode(HexagonISD::TYPECAST, dl, MVT::i1, VecV);
}
// If the value extracted is a single bit, use tstbit.
diff --git a/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp
index 6599970361700e..bbb9136a4e4d2a 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp
@@ -829,8 +829,7 @@ HexagonTargetLowering::buildHvxVectorReg(ArrayRef<SDValue> Values,
return DAG.getUNDEF(VecTy);
if (IsSplat) {
assert(SplatV.getNode());
- auto *IdxN = dyn_cast<ConstantSDNode>(SplatV.getNode());
- if (IdxN && IdxN->isZero())
+ if (isNullConstant(SplatV))
return getZero(dl, VecTy, DAG);
MVT WordTy = MVT::getVectorVT(MVT::i32, HwLen/4);
SDValue S = DAG.getNode(ISD::SPLAT_VECTOR, dl, WordTy, SplatV);
More information about the llvm-commits
mailing list