[Mlir-commits] [mlir] [mlir][vector] Add verification for incorrect vector.extract (PR #115824)
Diego Caballero
llvmlistbot at llvm.org
Tue Nov 12 15:22:08 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) ||
----------------
dcaballe wrote:
Yeah, things here were defined too loose and we have built on top of some of the corner cases. I have a few things in mind to improve this a bit more but we have to go one step at a time and see how people feel about it...
https://github.com/llvm/llvm-project/pull/115824
More information about the Mlir-commits
mailing list