[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 00:28:51 PST 2025


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

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

Sorry for the late reply.

> I don't quite see the problem with this though, seems like the kind of usual transformations we do.

Do you really think adding result values to `scf.while` is fine? From my perspective, it introduces dead values, and they cannot be eliminated by CSE, which makes it risky.
The root cause is that values in the `before` region of `scf.while` cannot reach the `do` region, and passing values to the `do` region is tightly coupled with the result values. This already makes me question whether the design of `scf.while` is reasonable—why does it use two regions instead of two basic blocks?

> Do you have examples of compile-time issue? I'd rather be specific and be able to measure the issue here. Collecting values and manipulating def-use chains should be OK here, as long as there is no complex analysis required beyond the direct chains.

This is just my subjective guess. Maybe I was being lazy, since the revised implementation would require additional analysis and make the code more complex. So I chose to specialize the implementation to meet my current needs. I’ll probably consider improving it further only when new requirements arise.



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


More information about the Mlir-commits mailing list