[Mlir-commits] [mlir] [mlir][vector] Add verification for incorrect vector.extract (PR #115824)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Tue Nov 12 04:36:11 PST 2024
================
@@ -1349,13 +1349,33 @@ LogicalResult vector::ExtractOp::verify() {
"corresponding dynamic position) -- this can only happen due to an "
"incorrect fold/rewrite");
auto position = getMixedPosition();
- if (position.size() > static_cast<unsigned>(getSourceVectorType().getRank()))
+ VectorType srcVecType = getSourceVectorType();
+ int64_t srcRank = srcVecType.getRank();
+ if (position.size() > static_cast<unsigned>(srcRank))
return emitOpError(
"expected position attribute of rank no greater than vector rank");
+
+ VectorType dstVecType = dyn_cast<VectorType>(getResult().getType());
+ if (dstVecType) {
+ int64_t srcRankMinusIndices = srcRank - getNumIndices();
+ int64_t dstRank = dstVecType.getRank();
+ if ((srcRankMinusIndices == 0 && dstRank != 1) ||
----------------
banach-space wrote:
This discussion might clarify things a bit: https://github.com/llvm/llvm-project/pull/115717
https://github.com/llvm/llvm-project/pull/115824
More information about the Mlir-commits
mailing list