[PATCH] D77663: WIP: [MLIR] Lower vector slices while lowering linalg to LLVM.

Pierre Oechsel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 02:41:53 PDT 2020


poechsel updated this revision to Diff 257636.
poechsel marked an inline comment as done.
poechsel added a comment.

Rebase, address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77663/new/

https://reviews.llvm.org/D77663

Files:
  mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
  mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
  mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp


Index: mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
===================================================================
--- mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
+++ mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
@@ -1230,6 +1230,15 @@
   patterns.insert<VectorMatmulOpConversion>(ctx, converter);
 }
 
+void mlir::lowerVectorToVector(Operation *op, MLIRContext *context) {
+  // Perform progressive lowering of operations on slices and
+  // all contraction operations. Also applies folding and DCE.
+  OwningRewritePatternList patterns;
+  populateVectorSlicesLoweringPatterns(patterns, context);
+  populateVectorContractLoweringPatterns(patterns, context);
+  applyPatternsAndFoldGreedily(op, patterns);
+}
+
 namespace {
 struct LowerVectorToLLVMPass
     : public ConvertVectorToLLVMBase<LowerVectorToLLVMPass> {
@@ -1238,14 +1247,7 @@
 } // namespace
 
 void LowerVectorToLLVMPass::runOnOperation() {
-  // Perform progressive lowering of operations on slices and
-  // all contraction operations. Also applies folding and DCE.
-  {
-    OwningRewritePatternList patterns;
-    populateVectorSlicesLoweringPatterns(patterns, &getContext());
-    populateVectorContractLoweringPatterns(patterns, &getContext());
-    applyPatternsAndFoldGreedily(getOperation(), patterns);
-  }
+  lowerVectorToVector(getOperation(), &getContext());
 
   // Convert to the LLVM IR dialect.
   LLVMTypeConverter converter(&getContext());
Index: mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
===================================================================
--- mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
+++ mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
@@ -569,6 +569,7 @@
 void ConvertLinalgToLLVMPass::runOnOperation() {
   auto module = getOperation();
 
+  lowerVectorToVector(module, &getContext());
   // Convert to the LLVM IR dialect using the converter defined above.
   OwningRewritePatternList patterns;
   LLVMTypeConverter converter(&getContext());
Index: mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
===================================================================
--- mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
+++ mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
@@ -28,6 +28,10 @@
 /// Create a pass to convert vector operations to the LLVMIR dialect.
 std::unique_ptr<OperationPass<ModuleOp>> createConvertVectorToLLVMPass();
 
+// Perform progressive lowering of operations on "slices" and
+// all contraction operations. Also applies folding and DCE.
+void lowerVectorToVector(Operation *op, MLIRContext *context);
+
 } // namespace mlir
 
 #endif // MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLLVM_H_


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77663.257636.patch
Type: text/x-patch
Size: 2728 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200415/0e0b1484/attachment.bin>


More information about the llvm-commits mailing list