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

Benjamin Kramer llvmlistbot at llvm.org
Wed Jul 29 05:56:30 PDT 2026


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

`[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

>From 1ce4290ed1a5f6639d2ffd6078a7a249d366b976 Mon Sep 17 00:00:00 2001
From: Benjamin Kramer <benny.kra at googlemail.com>
Date: Wed, 29 Jul 2026 14:49:47 +0200
Subject: [PATCH] [mlir] Honor IntrHasSideEffects on IntrNoMem LLVM intrinsics

[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
---
 mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

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



More information about the Mlir-commits mailing list