[Mlir-commits] [mlir] [MLIR] Add missing memory read effect on memref.reshape (PR #117130)

Uday Bondhugula llvmlistbot at llvm.org
Tue Dec 3 22:34:48 PST 2024


bondhugula wrote:

> That should be testable I think? We don't have a transformation where this can be visible?

Yes, this should be testable. There are multiple affine analysis utilities that check for ops with mem read effects:
```
lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp:          (hasEffect<MemoryEffects::Read>(user, memref) &&
lib/Dialect/Affine/Utils/Utils.cpp:mlir::affine::hasNoInterveningEffect<mlir::MemoryEffects::Read,
lib/Dialect/Affine/Utils/Utils.cpp:    if (!affine::hasNoInterveningEffect<MemoryEffects::Read>(writeA, writeB,
```
Any of the passes relying on these utilities (affine-scalrep and affine-licm) will be able to exercise this. I can construct a test case.
```
affine.store ..., %M[...]  // S1.
memref.reshape %x, %M
affine.store ..., %M[...]  // S2.
```
Now, S1 should not be dead if the read effect is properly defined on `memref.reshape`.

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


More information about the Mlir-commits mailing list