[llvm] r353646 - [DAG] Add optional AllowUndefs to isNullOrNullSplat

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 10 09:42:15 PST 2019


Author: rksimon
Date: Sun Feb 10 09:42:15 2019
New Revision: 353646

URL: http://llvm.org/viewvc/llvm-project?rev=353646&view=rev
Log:
[DAG] Add optional AllowUndefs to isNullOrNullSplat

No change in default behaviour (AllowUndefs = false)

Modified:
    llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=353646&r1=353645&r2=353646&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Sun Feb 10 09:42:15 2019
@@ -1633,9 +1633,9 @@ ConstantSDNode *isConstOrConstSplat(SDVa
 ConstantFPSDNode *isConstOrConstSplatFP(SDValue N, bool AllowUndefs = false);
 
 /// Return true if the value is a constant 0 integer or a splatted vector of
-/// a constant 0 integer (with no undefs).
+/// a constant 0 integer (with no undefs by default).
 /// Build vector implicit truncation is not an issue for null values.
-bool isNullOrNullSplat(SDValue V);
+bool isNullOrNullSplat(SDValue V, bool AllowUndefs = false);
 
 /// Return true if the value is a constant 1 integer or a splatted vector of a
 /// constant 1 integer (with no undefs).

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=353646&r1=353645&r2=353646&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sun Feb 10 09:42:15 2019
@@ -7128,11 +7128,7 @@ SDValue DAGCombiner::visitFunnelShift(SD
       return IsFSHL ? N0 : N1;
 
   auto IsUndefOrZero = [](SDValue V) {
-    if (V.isUndef())
-      return true;
-    if (ConstantSDNode *Cst = isConstOrConstSplat(V, /*AllowUndefs*/true))
-      return Cst->getAPIntValue() == 0;
-    return false;
+    return V.isUndef() || isNullOrNullSplat(V, /*AllowUndefs*/ true);
   };
 
   if (ConstantSDNode *Cst = isConstOrConstSplat(N2)) {

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=353646&r1=353645&r2=353646&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sun Feb 10 09:42:15 2019
@@ -8622,9 +8622,9 @@ ConstantFPSDNode *llvm::isConstOrConstSp
   return nullptr;
 }
 
-bool llvm::isNullOrNullSplat(SDValue N) {
+bool llvm::isNullOrNullSplat(SDValue N, bool AllowUndefs) {
   // TODO: may want to use peekThroughBitcast() here.
-  ConstantSDNode *C = isConstOrConstSplat(N);
+  ConstantSDNode *C = isConstOrConstSplat(N, AllowUndefs);
   return C && C->isNullValue();
 }
 




More information about the llvm-commits mailing list