[llvm] 346f16d - [DAG] Move isNullConstantOrUndef helper to SelectionDAGNodes.h to allow other future uses. NFC.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 12 08:33:46 PDT 2024


Author: Simon Pilgrim
Date: 2024-06-12T16:32:36+01:00
New Revision: 346f16d504ab66f09e748a3ca041fa3a4deeeb1e

URL: https://github.com/llvm/llvm-project/commit/346f16d504ab66f09e748a3ca041fa3a4deeeb1e
DIFF: https://github.com/llvm/llvm-project/commit/346f16d504ab66f09e748a3ca041fa3a4deeeb1e.diff

LOG: [DAG] Move isNullConstantOrUndef helper to SelectionDAGNodes.h to allow other future uses. NFC.

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/SelectionDAGNodes.h
    llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
index 2edb039cbbfd2..2f36c2e86b1c3 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -1754,6 +1754,9 @@ class ConstantFPSDNode : public SDNode {
 /// Returns true if \p V is a constant integer zero.
 bool isNullConstant(SDValue V);
 
+/// Returns true if \p V is a constant integer zero or an UNDEF node.
+bool isNullConstantOrUndef(SDValue V);
+
 /// Returns true if \p V is an FP constant with a value of positive zero.
 bool isNullFPConstant(SDValue V);
 

diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 523d3aea66225..5b16c2effa39d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -11753,6 +11753,10 @@ bool llvm::isNullConstant(SDValue V) {
   return Const != nullptr && Const->isZero();
 }
 
+bool llvm::isNullConstantOrUndef(SDValue V) {
+  return V.isUndef() || isNullConstant(V);
+}
+
 bool llvm::isNullFPConstant(SDValue V) {
   ConstantFPSDNode *Const = dyn_cast<ConstantFPSDNode>(V);
   return Const != nullptr && Const->isZero() && !Const->isNegative();

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
index 8e5662a3cd818..ae6fdb594a2ef 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
@@ -24,10 +24,6 @@ using namespace llvm;
 
 namespace {
 
-static inline bool isNullConstantOrUndef(SDValue V) {
-  return V.isUndef() || isNullConstant(V);
-}
-
 static inline bool getConstantValue(SDValue N, uint32_t &Out) {
   // This is only used for packed vectors, where using 0 for undef should
   // always be good.


        


More information about the llvm-commits mailing list