[mlir][vector] Support for extracting 1-element vectors in VectorExtractOpConversion (#107549)

This patch adds support for converting `vector.extract` that extract
1-element vectors into LLVM, fixing a crash in such cases.
E.g., `vector.extract %1[0]: vector<1xf32> from vector<2xf32>`. Fix
#61372.
This commit is contained in:
Longsheng Mou
2024-09-11 17:10:58 +08:00
committed by GitHub
parent a8f3d30312
commit a4b0153c4f
2 changed files with 28 additions and 1 deletions

View File

@@ -1104,7 +1104,10 @@ public:
}
// One-shot extraction of vector from array (only requires extractvalue).
if (isa<VectorType>(resultType)) {
// Except for extracting 1-element vectors.
if (isa<VectorType>(resultType) &&
position.size() !=
static_cast<size_t>(extractOp.getSourceVectorType().getRank())) {
if (extractOp.hasDynamicPosition())
return failure();