[mlir][vector] Fix double rank reducing folding bug
authorLei Zhang <antiagainst@google.com>
Fri, 30 Sep 2022 20:46:34 +0000 (16:46 -0400)
committerLei Zhang <antiagainst@google.com>
Fri, 30 Sep 2022 20:50:48 +0000 (16:50 -0400)
commit9e8e4779a2627de41a17766acc310f131673750b
tree93a652a9bac734e57978e7b880d5a31c074a42fd
parentb1985dd74de8c5c0d9eeec0a912ad3f42d0b2c0a
[mlir][vector] Fix double rank reducing folding bug

In https://reviews.llvm.org/D133883, we changed the
`FoldExtractSliceIntoTransferRead` pattern from requiring
full identity map to minor identity map. This effectively
allows rank reducing `vector.transfer_read` ops. However,
the logic for checking `tensor.extract_slice` rank reducing
still looks at the vector rank, which now could be smaller
than the `tensor.extract_slice`'s output tensor rank.
It ends up we can have incorrect index cacluation after
folding due to this double rank reducing behavior.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D134984
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
mlir/test/Dialect/Vector/canonicalize.mlir