[Mlir-commits] [mlir] [mlir][scf] Add simple LICM pattern for `scf.while` (PR #76370)
Matthias Springer
llvmlistbot at llvm.org
Fri Jan 5 07:37:42 PST 2024
https://github.com/matthias-springer commented:
We already have a LICM pass that hoists ops from loops. (I recently extended it to support `scf.while`.) This change duplicates a part of the LICM pass in a canonicalization pattern.
Your `scf.while` uplifting pattern is probably just one example of a pattern that is enabled by LICM, so I'd be in favor of handling this in a more generic way: we could apply LICM as part of every greedy pattern rewrite, before or after each greedy pattern rewriter iteration (https://github.com/llvm/llvm-project/blob/main/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp#L763). We already perform various IR optimizations in there: region simplification and constant de-duplication. In practice, the latter is often a form of LICM (when CSE'ing a constant outside of a loop with a constant inside of a loop), so there is some precedent.
https://github.com/llvm/llvm-project/pull/76370
More information about the Mlir-commits
mailing list