[Mlir-commits] [mlir] [MLIR][SCF] Sink scf.if from scf.while before region into after region. (PR #165216)

Ming Yan llvmlistbot at llvm.org
Wed Nov 26 08:48:32 PST 2025


================

----------------
NexMing wrote:

> I don't quite see what CSE has to do with these?

Oh, sorry — I mistakenly wrote CSE instead of DCE. I mean that DCE optimization cannot eliminate it.

> seems like the kind of usual transformations we do.

I find it hard to accept the statement. Does this mean that your transformations may also produce dead values that cannot be eliminated? Have you considered extreme cases or stress tests? Or could this actually be a hidden optimization bug that simply hasn’t been discovered yet?

> What concrete problem do you expect from this actually?

Subjectively, I feel that adding result values to `scf.while` may introduce negative optimization effects. Maybe I just don’t understand it well enough — can you explain why it wouldn’t cause any negative optimization?

> If you're interest is to pattern match the specific pattern produced by `lift-cf-to-scf`, then it may be a better fit in this pass than as a canonicalization because of this implicit coupling.

If I can guarantee that it always results in a positive optimization, then I think it’s fine to use it in canonicalization.

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


More information about the Mlir-commits mailing list