[Mlir-commits] [mlir] [mlir][emitc] Only mark operator with fundamental type have no side effect (PR #144990)

Jianjian Guan llvmlistbot at llvm.org
Mon Aug 18 19:56:50 PDT 2025


================
@@ -57,7 +61,12 @@ class EmitC_BinaryOp<string mnemonic, list<Trait> traits = []> :
 
   let extraClassDeclaration = [{
     bool hasSideEffects() {
-      return false;
+      // If both operands are fundamental types, the operation is pure.
+      if (isFundamentalType(getOperand(0).getType()) 
+          && isFundamentalType(getOperand(1).getType())) {
+        return false;
+      }
+      return true;
----------------
jacquesguan wrote:

Addressed.

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


More information about the Mlir-commits mailing list