[Mlir-commits] [mlir] [mlir][scf] Relax requirements for loops fusion (PR #79187)
Ivan Butygin
llvmlistbot at llvm.org
Mon Jan 29 08:58:05 PST 2024
Hardcode84 wrote:
I think first case with multiple writes to the same indices is fine,
but I believe I have a counter-example for the second case with func arguments:
```
func.func @fuse_two(%A: memref, %B: memref) {
%temp = memref.alloc
scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) {
%A_elem = memref.load %A[%i, %j]
memref.store %A_elem, %temp[%i, %j] : memref<2x2xf32>
}
scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) {
%elem = memref.load %temp[%i, %j]
memref.store %elem, %B[%i, %j] : memref<2x2xf32>
}
}
```
If %A and %B alias same array with an different offset, the fusion will not be legal.
And generally, I would prefer to be conservative about handling functions arguments.
What you probably want is some sort of `restrict` attribute on function args, so user can
guarantee args do not alias. Upstream alias analysis doesn't support this, but this is the
reason I did aliasing hook configurable.
Regarding broken tests, they probably can be fixed by making some memrefs local allocations instead
of functions args.
https://github.com/llvm/llvm-project/pull/79187
More information about the Mlir-commits
mailing list