[PATCH] D118614: [NFC] Remove isConstFalseVal in favour of using isNullOrNullSplat

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 31 08:25:39 PST 2022


david-arm created this revision.
david-arm added reviewers: sdesmalen, peterwaller-arm, kmclaughlin, spatel.
Herald added subscribers: ecnelises, hiraditya.
david-arm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

It turns out that isConstFalseVal doesn't add any value over just
using isNullOrNullSplat, so it makes sense to remove redundant
interfaces.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118614

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp


Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -3207,30 +3207,6 @@
   llvm_unreachable("Invalid boolean contents");
 }
 
-bool TargetLowering::isConstFalseVal(const SDNode *N) const {
-  if (!N)
-    return false;
-
-  const ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N);
-  if (!CN) {
-    const BuildVectorSDNode *BV = dyn_cast<BuildVectorSDNode>(N);
-    if (!BV)
-      return false;
-
-    // Only interested in constant splats, we don't care about undef
-    // elements in identifying boolean constants and getConstantSplatNode
-    // returns NULL if all ops are undef;
-    CN = BV->getConstantSplatNode();
-    if (!CN)
-      return false;
-  }
-
-  if (getBooleanContents(N->getValueType(0)) == UndefinedBooleanContent)
-    return !CN->getAPIntValue()[0];
-
-  return CN->isZero();
-}
-
 bool TargetLowering::isExtendedTrueVal(const ConstantSDNode *N, EVT VT,
                                        bool SExt) const {
   if (VT == MVT::i1)
@@ -3742,7 +3718,7 @@
         if (TopSetCC.getValueType() == MVT::i1 && VT == MVT::i1 &&
             TopSetCC.getOpcode() == ISD::SETCC &&
             (N0Opc == ISD::ZERO_EXTEND || N0Opc == ISD::SIGN_EXTEND) &&
-            (isConstFalseVal(N1C) ||
+            (isNullOrNullSplat(N1) ||
              isExtendedTrueVal(N1C, N0->getValueType(0), SExt))) {
 
           bool Inverse = (N1C->isZero() && Cond == ISD::SETEQ) ||
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -909,7 +909,7 @@
 
   if (N.getOpcode() != ISD::SELECT_CC ||
       !TLI.isConstTrueVal(N.getOperand(2).getNode()) ||
-      !TLI.isConstFalseVal(N.getOperand(3).getNode()))
+      !isNullOrNullSplat(N.getOperand(3)))
     return false;
 
   if (TLI.getBooleanContents(N.getValueType()) ==
Index: llvm/include/llvm/CodeGen/TargetLowering.h
===================================================================
--- llvm/include/llvm/CodeGen/TargetLowering.h
+++ llvm/include/llvm/CodeGen/TargetLowering.h
@@ -3678,10 +3678,6 @@
   /// from getBooleanContents().
   bool isConstTrueVal(const SDNode *N) const;
 
-  /// Return if the N is a constant or constant vector equal to the false value
-  /// from getBooleanContents().
-  bool isConstFalseVal(const SDNode *N) const;
-
   /// Return if \p N is a True value when extended to \p VT.
   bool isExtendedTrueVal(const ConstantSDNode *N, EVT VT, bool SExt) const;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118614.404541.patch
Type: text/x-patch
Size: 2709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220131/45f9a62f/attachment.bin>


More information about the llvm-commits mailing list