[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 12:37:24 PST 2024


================
@@ -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; }
----------------
s-barannikov wrote:

Note that this opcode check doesn't really tell us which union member is active because `INTRINSIC_W_CHAIN` / `INTRINSIC_VOID` can either be an ordinary `SDNode` or `MemIntrinsicSDNode`. If I read the removed comment correctly, this bit was introduced to disambiguate these cases, but introducing it also made the opcode check redundant.

Assuming there is no (pre-existing) undefined behavior, just checking the bit is more robust as the method will now return false for ordinary `SDNode`s erroneously created with `isTargetMemoryOpcode` opcodes.


https://github.com/llvm/llvm-project/pull/115720


More information about the llvm-commits mailing list