[llvm] [SelectionDAG] Update MemOp to distinguish memmove from memcpy (PR #206005)

Ömer Sinan Ağacan via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 26 04:33:31 PDT 2026


================
@@ -168,19 +182,25 @@ struct MemOp {
     return DstAlign;
   }
   bool isFixedDstAlign() const { return !DstAlignCanChange; }
-  bool allowOverlap() const { return AllowOverlap; }
-  bool isMemset() const { return IsMemset; }
-  bool isMemcpy() const { return !IsMemset; }
-  bool isMemcpyWithFixedDstAlign() const {
-    return isMemcpy() && !DstAlignCanChange;
+  bool allowOverlap() const { return !IsVolatile; }
+  bool isMemset() const {
+    return Kind == MemOpKind::Memset || Kind == MemOpKind::MemsetWithZero;
+  }
+  bool isMemcpy() const {
+    return Kind == MemOpKind::Memcpy || Kind == MemOpKind::MemcpyStrSrc;
+  }
+  bool isMemmove() const { return Kind == MemOpKind::Memmove; }
+  bool isMemcpyOrMemmove() const { return isMemcpy() || isMemmove(); }
+  bool isMemcpyOrMemmoveWithFixedDstAlign() const {
+    return isMemcpyOrMemmove() && !DstAlignCanChange;
   }
-  bool isZeroMemset() const { return isMemset() && ZeroMemset; }
+  bool isZeroMemset() const { return Kind == MemOpKind::MemsetWithZero; }
   bool isMemcpyStrSrc() const {
-    assert(isMemcpy() && "Must be a memcpy");
-    return MemcpyStrSrc;
+    assert(isMemcpyOrMemmove() && "Must be a memcpy or memmove");
+    return Kind == MemOpKind::MemcpyStrSrc;
----------------
osa1 wrote:

Why? Previously the assertion would fire when the `MemOp` is for a `memmove` or `memcpy`. For it to fire the same way we need to update it from `isMemcpy` to `isMemCpyOrMemmove`. (it fires when you call it on a `memset`)

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


More information about the llvm-commits mailing list