[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 11 01:32:50 PDT 2025
================
@@ -57,7 +61,18 @@ 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;
+ }
+ // Pointer arithmetic operations is pure.
+ if (isa<emitc::PointerType>(getOperand(0).getType())
+ && (isFundamentalType(getOperand(1).getType()) ||
+ isa<emitc::PointerType>(getOperand(1).getType()))) {
+ return false;
----------------
jacquesguan wrote:
Changed `isFundamentalType()` including `emitc::PointerType`.
https://github.com/llvm/llvm-project/pull/144990
More information about the Mlir-commits
mailing list