[mlir][Vector] Add folding of vector transfers from/into tensor producing ops.
authorNicolas Vasilache <nicolas.vasilache@gmail.com>
Thu, 4 Mar 2021 14:09:54 +0000 (14:09 +0000)
committerNicolas Vasilache <nicolas.vasilache@gmail.com>
Thu, 4 Mar 2021 14:17:42 +0000 (14:17 +0000)
commitf3cc8543647cfcfd3ea383e6738bc58a258d6f74
tree17188f0f11735b47753c056fcf633fc3dddfe525
parent2e90fc2c407bb9a85e14fa2c75533a984e5a765a
[mlir][Vector] Add folding of vector transfers from/into tensor producing ops.

Add a folder to rewrite a sequence such as:

```
   %t1 = ...
   %v = vector.transfer_read %t0[%c0...], {masked = [false...]} :
     tensor<static_sizesxf32>, vector<static_sizesxf32>
  %t2 = vector.transfer_write %v, %t1[%c0...] {masked = [false...]} :
     vector<static_sizesxf32>, tensor<static_sizesxf32>
```

into:

```
   %t0
```

The producer of t1 may or may not be DCE'd depending on whether it is a
block argument or has side effects.

Differential revision: https://reviews.llvm.org/D97934
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/test/Dialect/Vector/canonicalize.mlir