[Mlir-commits] [mlir] [mlir][SCFToOpenMP] Use walk pattern driver (PR #155242)

Markus Böck llvmlistbot at llvm.org
Tue Aug 26 02:25:39 PDT 2025


================
@@ -538,15 +538,16 @@ struct ParallelOpLowering : public OpRewritePattern<scf::ParallelOp> {
 
 /// Applies the conversion patterns in the given function.
 static LogicalResult applyPatterns(ModuleOp module, unsigned numThreads) {
-  ConversionTarget target(*module.getContext());
-  target.addIllegalOp<scf::ReduceOp, scf::ReduceReturnOp, scf::ParallelOp>();
-  target.addLegalDialect<omp::OpenMPDialect, LLVM::LLVMDialect,
-                         memref::MemRefDialect>();
-
   RewritePatternSet patterns(module.getContext());
   patterns.add<ParallelOpLowering>(module.getContext(), numThreads);
   FrozenRewritePatternSet frozen(std::move(patterns));
-  return applyPartialConversion(module, target, frozen);
+  walkAndApplyPatterns(module, frozen);
----------------
zero9178 wrote:

Could we leave a TODO here explaining why this uses the pattern rewriter rather than the dialect conversion, and that in an ideal world we'd use dialect conversion? It is the only rewriter that guarantees pattern application until all ops are legal after all. 

I am worried that introducing this here without a comment would legitimize using greedy pattern rewriter for dialect conversion when we shouldn't. 

https://github.com/llvm/llvm-project/pull/155242


More information about the Mlir-commits mailing list