[mlir] Allow empty position in vector.insert and vector.extract
Such ops are no-ops and are folded to their respective `source`/`vector` operand. Differential Revision: https://reviews.llvm.org/D101879
This commit is contained in:
@@ -656,6 +656,12 @@ public:
|
||||
if (!llvmResultType)
|
||||
return failure();
|
||||
|
||||
// Extract entire vector. Should be handled by folder, but just to be safe.
|
||||
if (positionArrayAttr.empty()) {
|
||||
rewriter.replaceOp(extractOp, adaptor.vector());
|
||||
return success();
|
||||
}
|
||||
|
||||
// One-shot extraction of vector from array (only requires extractvalue).
|
||||
if (resultType.isa<VectorType>()) {
|
||||
Value extracted = rewriter.create<LLVM::ExtractValueOp>(
|
||||
@@ -762,6 +768,13 @@ public:
|
||||
if (!llvmResultType)
|
||||
return failure();
|
||||
|
||||
// Overwrite entire vector with value. Should be handled by folder, but
|
||||
// just to be safe.
|
||||
if (positionArrayAttr.empty()) {
|
||||
rewriter.replaceOp(insertOp, adaptor.source());
|
||||
return success();
|
||||
}
|
||||
|
||||
// One-shot insertion of a vector into an array (only requires insertvalue).
|
||||
if (sourceType.isa<VectorType>()) {
|
||||
Value inserted = rewriter.create<LLVM::InsertValueOp>(
|
||||
|
||||
Reference in New Issue
Block a user