mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 12:26:52 +08:00
[MLIR] Avoid vector.extract_strided_slice when not needed (#115941)
In `staticallyExtractSubvector`, When the extracting slice is the same as source vector, do not need to emit `vector.extract_strided_slice`. This fixes the lit test case `@vector_store_i4` in `mlir\test\Dialect\Vector\vector-emulate-narrow-type.mlir`, where converting from `vector<8xi4>` to `vector<4xi8>` does not need slice extraction. The issue was introduced in #113411 and #115070, CI failure link: https://buildkite.com/llvm-project/github-pull-requests/builds/118845 This PR does not include a lit test case because it is a fix and the above mentioned `@vector_store_i4` test actually tests the mechanism. Signed-off-by: Alan Li <me@alanli.org>
This commit is contained in:
@@ -150,6 +150,13 @@ static Value staticallyExtractSubvector(OpBuilder &rewriter, Location loc,
|
||||
assert((vectorType.getRank() == 1 && extractType.getRank() == 1) &&
|
||||
"expected 1-D source and destination types");
|
||||
(void)vectorType;
|
||||
assert(frontOffset + subvecSize <= vectorType.getNumElements() &&
|
||||
"subvector out of bounds");
|
||||
|
||||
// do not need extraction if the subvector size is the same as the source
|
||||
if (vectorType.getNumElements() == subvecSize)
|
||||
return source;
|
||||
|
||||
auto offsets = rewriter.getI64ArrayAttr({frontOffset});
|
||||
auto sizes = rewriter.getI64ArrayAttr({subvecSize});
|
||||
auto strides = rewriter.getI64ArrayAttr({1});
|
||||
|
||||
Reference in New Issue
Block a user