[Mlir-commits] [mlir] [mlir][scf] Add simple LICM pattern for `scf.while` (PR #76370)

Renato Golin llvmlistbot at llvm.org
Sat Jan 6 05:19:00 PST 2024


rengolin wrote:

> Actually you're saying the opposite of me :)

:sweat_smile:

It's confusing, because I agree with your statement and still think LICM should be LICM, not canonicalization. Not because the two snippets you show are different (they're not), but because these are well known passes (like CSE, DCE) which are arguably all forms of canonicalization. 

So, we either call every transform pass that doesn't change program semantics "canonicalization", or we keep them in separate passes because some canonicalizations are different than others. I strongly prefer the latter, because of my second point earlier: the control that some bundle-of-passes can have on which types of canonicalization can happen in between its inner transformations.

> the argument that the second one "may increase register pressure" (for example, use any kind of target-specific optimization) is not a valid objection to canonicalization. (and I would want my compiler to treat these two program identically)

Indeed. Register/memory allocators should operate on canonical forms and do their most optimal work in those forms.

However, the argument itself is still valid. If you interpret this as "the canonical form is changing, and the following passes were coded with the previous canonical form in mind", then my argument about isolating following passes is broken and we need to think about the consequences.

But it feels to me that we're driving away from the initial aims of this PR. To the code here, it shouldn't matter if this transform is in pass A or B, as long as the pass runs before the `while`-to-`for` conversion, it should be fine.

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


More information about the Mlir-commits mailing list