aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Conversion/VectorToLLVM
diff options
context:
space:
mode:
authorMatthias Springer <springerm@google.com>2021-05-13 12:53:15 +0900
committerMatthias Springer <springerm@google.com>2021-05-13 12:54:18 +0900
commit864adf399e58a6bfd823136fc2cbcfe9dff5b4a8 (patch)
tree93f73b267e629b9d7d46c2ca565c7d06f693f324 /mlir/lib/Conversion/VectorToLLVM
parentc52cbe63e42fff8c1a95921effd35d7bb59301d3 (diff)
[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
Diffstat (limited to 'mlir/lib/Conversion/VectorToLLVM')
-rw-r--r--mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
index 9ecee857e2e5..9db34d7411e9 100644
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
@@ -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>(