[Mlir-commits] [mlir] [mlir] Honor IntrHasSideEffects on IntrNoMem LLVM intrinsics (PR #212760)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jul 29 05:57:25 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-core

Author: Benjamin Kramer (d0k)

<details>
<summary>Changes</summary>

`[IntrNoMem, IntrHasSideEffects]` is a perfectly valid intrinsic trait combination, and MLIR would CSE/DCE those without checking. This mirrors how LLVM models this, see getEffectiveME in IntrinsicEmitter.cpp

@<!-- -->vsytch

---
Full diff: https://github.com/llvm/llvm-project/pull/212760.diff


1 Files Affected:

- (modified) mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp (+7-3) 


``````````diff
diff --git a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp
index 54cc4b79a36b1..ea72ae974c585 100644
--- a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp
+++ b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp
@@ -161,11 +161,15 @@ class LLVMIntrinsic {
   }
 
   /// Return true if the intrinsic may have side effects, i.e. does not have the
-  /// `IntrNoMem` property.
+  /// `IntrNoMem` property or has the `IntrHasSideEffects` property.
   bool hasSideEffects() const {
     return llvm::none_of(
-        record.getValueAsListOfDefs(fieldTraits),
-        [](const Record *r) { return r->getName() == "IntrNoMem"; });
+               record.getValueAsListOfDefs(fieldTraits),
+               [](const Record *r) { return r->getName() == "IntrNoMem"; }) ||
+           llvm::any_of(record.getValueAsListOfDefs(fieldTraits),
+                        [](const Record *r) {
+                          return r->getName() == "IntrHasSideEffects";
+                        });
   }
 
   /// Return true if the intrinsic is commutative, i.e. has the respective

``````````

</details>


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


More information about the Mlir-commits mailing list