[llvm] [SelectionDAG] Simplify classof of MemSDNode and MemIntrinsicSDNode (NFC) (PR #115720)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 11 06:36:34 PST 2024


https://github.com/s-barannikov created https://github.com/llvm/llvm-project/pull/115720

`SDNodeBits.IsMemIntrinsic` is set if and only if the node is an instance of `MemIntrinsicSDNode`. Thus, to check if a node is an instance of `MemIntrinsicSDNode` we only need to check this bit.

>From 0ddd631dcfcbf51579929fa26fb4380bfc430e8f Mon Sep 17 00:00:00 2001
From: Sergei Barannikov <barannikov88 at gmail.com>
Date: Mon, 11 Nov 2024 17:34:17 +0300
Subject: [PATCH] [SelectionDAG] Simplify classof of MemSDNode and
 MemIntrinsicSDNode (NFC)

`SDNodeBits.IsMemIntrinsic` is set if and only if the node is an
instance of `MemIntrinsicSDNode`. Thus, to check if a node is an
instance of `MemIntrinsicSDNode` we only need to check this bit.
---
 llvm/include/llvm/CodeGen/SelectionDAGNodes.h | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
index 739ce05e947346..677b59e0c8fbeb 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -708,15 +708,7 @@ END_TWO_BYTE_PACK()
   bool isUndef() const { return NodeType == ISD::UNDEF; }
 
   /// Test if this node is a memory intrinsic (with valid pointer information).
-  /// INTRINSIC_W_CHAIN and INTRINSIC_VOID nodes are sometimes created for
-  /// non-memory intrinsics (with chains) that are not really instances of
-  /// MemSDNode. For such nodes, we need some extra state to determine the
-  /// proper classof relationship.
-  bool isMemIntrinsic() const {
-    return (NodeType == ISD::INTRINSIC_W_CHAIN ||
-            NodeType == ISD::INTRINSIC_VOID) &&
-           SDNodeBits.IsMemIntrinsic;
-  }
+  bool isMemIntrinsic() const { return SDNodeBits.IsMemIntrinsic; }
 
   /// Test if this node is a strict floating point pseudo-op.
   bool isStrictFPOpcode() {
@@ -1464,7 +1456,6 @@ class MemSDNode : public SDNode {
     switch (N->getOpcode()) {
     case ISD::LOAD:
     case ISD::STORE:
-    case ISD::PREFETCH:
     case ISD::ATOMIC_CMP_SWAP:
     case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS:
     case ISD::ATOMIC_SWAP:
@@ -1504,7 +1495,7 @@ class MemSDNode : public SDNode {
     case ISD::EXPERIMENTAL_VECTOR_HISTOGRAM:
       return true;
     default:
-      return N->isMemIntrinsic() || N->isTargetMemoryOpcode();
+      return N->isMemIntrinsic();
     }
   }
 };
@@ -1596,9 +1587,7 @@ class MemIntrinsicSDNode : public MemSDNode {
   static bool classof(const SDNode *N) {
     // We lower some target intrinsics to their target opcode
     // early a node with a target opcode can be of this class
-    return N->isMemIntrinsic()             ||
-           N->getOpcode() == ISD::PREFETCH ||
-           N->isTargetMemoryOpcode();
+    return N->isMemIntrinsic();
   }
 };
 



More information about the llvm-commits mailing list