[mlir][vector] Fold scalar vector.extract of non-splat n-D constants
authorJakub Kuderski <kubak@google.com>
Wed, 14 Sep 2022 00:30:33 +0000 (20:30 -0400)
committerJakub Kuderski <kubak@google.com>
Wed, 14 Sep 2022 00:30:50 +0000 (20:30 -0400)
commit8c2ea14436c8232fa2e496122cb1d9349b1d8737
tree36beccd8cc6f972b3d85029aa91a1c28416fb70f
parent49f3f976740854b1751d9dfc7f20e306c0d95fa9
[mlir][vector] Fold scalar vector.extract of non-splat n-D constants

Add a new pattern to fold `vector.extract` over n-D constants that extract scalars.
The previous code handled ND splat constants only. The new pattern is conservative and does handle sub-vector constants.

This is to aid the `arith::EmulateWideInt` pass which emits a lot of 2-element vector constants.

Reviewed By: Mogball, dcaballe

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