[Mlir-commits] [mlir] [mlir] Enable decoupling two kinds of greedy behavior. (PR #104649)

Mehdi Amini llvmlistbot at llvm.org
Tue Sep 3 12:41:19 PDT 2024


================
@@ -117,10 +126,18 @@ class GreedyRewriteConfig {
 ///
 /// Note: This method does not apply patterns to the region's parent operation.
 LogicalResult
+applyPatternsGreedily(Region &region, const FrozenRewritePatternSet &patterns,
+                      GreedyRewriteConfig config = GreedyRewriteConfig(),
+                      bool *changed = nullptr);
+/// Same as `applyPatternsAndGreedily` above with folding.
+inline LogicalResult
 applyPatternsAndFoldGreedily(Region &region,
                              const FrozenRewritePatternSet &patterns,
                              GreedyRewriteConfig config = GreedyRewriteConfig(),
-                             bool *changed = nullptr);
+                             bool *changed = nullptr) {
+  config.fold = true;
+  return applyPatternsGreedily(region, patterns, config, changed);
+}
 
----------------
joker-eph wrote:

> The top one means it may fold, this one it must.

The top one with the right config is equivalent to this one, why would we have a separate API here? Why specifically for fold and not for other parameters of the config?

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


More information about the Mlir-commits mailing list