[Mlir-commits] [mlir] [MLIR][SCF] Handle commuted indices in parallel loop fusion (PR #219665)
Federico Bruzzone
llvmlistbot at llvm.org
Sat Aug 29 07:05:26 PDT 2026
================
@@ -145,6 +145,18 @@ static bool valsAreEquivalent(Value val1, Value val2,
return false;
if (!isMemoryEffectFree(val1DefOp) || !isMemoryEffectFree(val2DefOp))
return false;
+
+ // Handle commuted integer additions.
+ if (auto addOp1 = dyn_cast<arith::AddIOp>(val1DefOp)) {
+ if (auto addOp2 = dyn_cast<arith::AddIOp>(val2DefOp);
+ addOp2 &&
+ val1DefOp->getAttrDictionary() == val2DefOp->getAttrDictionary() &&
+ val1.getType() == val2.getType() &&
+ valsAreEquivalent(addOp1.getLhs(), addOp2.getRhs(), loopsIVsMap) &&
+ valsAreEquivalent(addOp1.getRhs(), addOp2.getLhs(), loopsIVsMap))
+ return true;
+ }
+
return OperationEquivalence::isEquivalentTo(
----------------
FedericoBruzzone wrote:
`OperationEquivalence::isEquivalentTo` has an additional last parameter: `checkCommutativeEquivalent` (which is a `function_ref`). See
https://github.com/llvm/llvm-project/blob/a2600d408cfbc328131bf2317426e2de1e50eed1/mlir/lib/IR/OperationSupport.cpp#L837-L842
Can we use this parameter to cover other commutative operations as well?
https://github.com/llvm/llvm-project/pull/219665
More information about the Mlir-commits
mailing list