[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 22:34:52 PST 2025


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

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

> I don't see any issue with what you call "dead values" here. But let's not reverse the burden of explanation: if you claim that this is a problem, it's up to you to provide an example (you just need one), not the opposite actually (I can't provide an example for the absence of something in general...).

I believe that the "seems like the kind of usual transformations we do." as you referred to, generally do not generate dead values that cannot be eliminated.

in the following example
```
%res = scf.while {
  a large number of defined values...
  scf.if %cond {
    used a large number of values...
  }
  scf.condition %cond
} do {
  ...
```
The converted `scf.while` defines a large number of values, but most of them have no users, and it seems that other optimizations can hardly eliminate them.
```
%res:xxxx = scf.while {
  a large number of defined values...
  scf.condition %cond (carrying a large number of operands)
} do {
  used a large number of values...
  ...
```
This is my subjective guess that such a transformation might introduce optimization risks (it’s just a guess... and I believe I’m not the only one who would think so). You can question my guess, and you can also explain why there is no risk. But since there has been no reasonable explanation, it leaves me very confused...

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


More information about the Mlir-commits mailing list