[mlir][MemRef] Fix the simplification of extract_strided_metadata(subview)
authorQuentin Colombet <quentin.colombet@gmail.com>
Mon, 17 Oct 2022 19:40:19 +0000 (19:40 +0000)
committerQuentin Colombet <quentin.colombet@gmail.com>
Tue, 18 Oct 2022 19:29:49 +0000 (19:29 +0000)
commitdf455beedfcd4634450e5782d6bb4986218174e2
tree26d772b55b46e93b1752ad3a9128cda9ea0e509f
parent0bfd900150a85be236bd25a067d43a4afeff7124
[mlir][MemRef] Fix the simplification of extract_strided_metadata(subview)

Prior to this patch we were wrongly applying the sub-strides to the
computation of the final offset of the subview.

Put differently, we were computing the offset as:
```
offset = baseOffset + sum(subOffset#i * baseStrides#i * subSizes#i)
```
Whereas we should be doing:
```
offset = baseOffset + sum(subOffset#i * baseStrides#i)
```
I.e., drop the subSizes#i term from the sum.

Differential Revision: https://reviews.llvm.org/D136107
mlir/lib/Dialect/MemRef/Transforms/SimplifyExtractStridedMetadata.cpp
mlir/test/Dialect/MemRef/simplify-extract-strided-metadata.mlir