[Mlir-commits] [mlir] [mlir][scf] Considering affine.apply when fusing scf::ParallelOp (PR #80145)
Ivan Butygin
llvmlistbot at llvm.org
Wed Jan 31 15:58:30 PST 2024
================
@@ -102,8 +113,30 @@ static bool haveNoReadsAfterWriteExceptSameIndex(
return WalkResult::interrupt();
for (int i = 0, e = storeIndices.size(); i < e; ++i) {
if (firstToSecondPloopIndices.lookupOrDefault(storeIndices[i]) !=
- loadIndices[i])
- return WalkResult::interrupt();
+ loadIndices[i]) {
+ auto *storeIndexDefOp = storeIndices[i].getDefiningOp();
+ auto *loadIndexDefOp = loadIndices[i].getDefiningOp();
+ if (storeIndexDefOp && loadIndexDefOp) {
+ if (!isMemoryEffectFree(storeIndexDefOp))
+ return WalkResult::interrupt();
+ if (!isMemoryEffectFree(loadIndexDefOp))
+ return WalkResult::interrupt();
+ if (!OperationEquivalence::isEquivalentTo(
+ storeIndexDefOp, loadIndexDefOp,
+ [&](Value storeIndex, Value loadIndex) {
+ if (getInductionVarIndex(storeIndex, firstPloop) !=
----------------
Hardcode84 wrote:
If values are different and both are not the induction variables, this check will erroneously return `success` (please add test for this case too). I think you can do
```
firstToSecondPloopIndices.lookupOrDefault(val1) != firstToSecondPloopIndices.lookupOrDefault(val2)
```
And you won't need `getInductionVarIndex` func in this case too.
https://github.com/llvm/llvm-project/pull/80145
More information about the Mlir-commits
mailing list