[Mlir-commits] [mlir] [mlir][vector] Prevent incorrect vector.transfer_{read|write} hoisting (PR #66930)

Nicolas Vasilache llvmlistbot at llvm.org
Thu Sep 21 05:01:05 PDT 2023


nicolasvasilache wrote:

> In particular:
> 
> ```mlir
>       %r1 = vector.transfer_read %memref0[%i, %i], %cst: memref<?x?xf32>, vector<2xf32>
>       %u1 = "some_use"(%r1) : (vector<2xf32>) -> vector<2xf32>
>       vector.transfer_write %u1, %memref0[%i, %i] : vector<2xf32>, memref<?x?xf32>
> ```
> 
> While `%i` is loop-invariant (which could hint that hoisting would be safe), the value of `%r1` could actually change between the 1st and the 2nd iteration.

Your point about the value of %r1 changing is valid, however note that `vector<2xf32>` gets passed as an iter_arg of the function. There should be no visible effects of that transformation in the sequential case. However, we do know that there is a problem in the parallel case and it would generally be better to use the hoist tensor subsets transform instead (but there are other caveats).

Happy to jump on a call to dig deeper if useful.

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


More information about the Mlir-commits mailing list