[PATCH] D80137: [mlir] SCFToStandard: support any ops in and around the control flow ops
Alex Zinenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 20 07:37:34 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa7d88a90386d: [mlir] SCFToStandard: support any ops in and around the control flow ops (authored by ftynse).
Changed prior to commit:
https://reviews.llvm.org/D80137?vs=264653&id=265244#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80137/new/
https://reviews.llvm.org/D80137
Files:
mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp
mlir/test/Conversion/SCFToStandard/convert-to-cfg.mlir
Index: mlir/test/Conversion/SCFToStandard/convert-to-cfg.mlir
===================================================================
--- mlir/test/Conversion/SCFToStandard/convert-to-cfg.mlir
+++ mlir/test/Conversion/SCFToStandard/convert-to-cfg.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt -convert-scf-to-std %s | FileCheck %s
+// RUN: mlir-opt -allow-unregistered-dialect -convert-scf-to-std %s | FileCheck %s
// CHECK-LABEL: func @simple_std_for_loop(%{{.*}}: index, %{{.*}}: index, %{{.*}}: index) {
// CHECK-NEXT: br ^bb1(%{{.*}} : index)
@@ -398,3 +398,17 @@
}
return %0#0, %0#1 : f32, i64
}
+
+// Check that the conversion is not overly conservative wrt unknown ops, i.e.
+// that the presence of unknown ops does not prevent the conversion from being
+// applied.
+// CHECK-LABEL: @unknown_op_inside_loop
+func @unknown_op_inside_loop(%arg0: index, %arg1: index, %arg2: index) {
+ // CHECK-NOT: scf.for
+ scf.for %i = %arg0 to %arg1 step %arg2 {
+ // CHECK: unknown.op
+ "unknown.op"() : () -> ()
+ scf.yield
+ }
+ return
+}
Index: mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp
===================================================================
--- mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp
+++ mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp
@@ -407,8 +407,11 @@
void SCFToStandardPass::runOnOperation() {
OwningRewritePatternList patterns;
populateLoopToStdConversionPatterns(patterns, &getContext());
+ // Configure conversion to lower out scf.for, scf.if and scf.parallel.
+ // Anything else is fine.
ConversionTarget target(getContext());
- target.addLegalDialect<StandardOpsDialect>();
+ target.addIllegalOp<scf::ForOp, scf::IfOp, scf::ParallelOp>();
+ target.markUnknownOpDynamicallyLegal([](Operation *) { return true; });
if (failed(applyPartialConversion(getOperation(), target, patterns)))
signalPassFailure();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80137.265244.patch
Type: text/x-patch
Size: 1895 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200520/e8f94620/attachment.bin>
More information about the llvm-commits
mailing list