[llvm] [Passes] Run SimpleLoopUnswitch after introducing invariant branches. (PR #81271)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 05:01:55 PDT 2024


fhahn wrote:

> So, is it an option to add IndVarSimplify to LPM1? (I don't think it makes any changes that would invalidate MSSA, so that should be fairly straightforward to add) Does it address the use case you are looking at? And following up with the same question as for the current approach: what's the compile time vs execution time impact then? i.e. is it worth adding it?

I finally had time to try this out in https://github.com/llvm/llvm-project/commit/aff602c6f3d9b66d7539d72e9f78adbf49118890, apologies for the long delay.

The impact of moving `indVarSimplify` to LPM1 is much bigger, both in terms of compile-time and binary changes: https://llvm-compile-time-tracker.com/compare.php?from=1d06f41b72e429a5b3ba318ff639b8b997e21ff8&to=aff602c6f3d9b66d7539d72e9f78adbf49118890&stat=instructions:u. I think a number of optimizations went into`IndVarSimplify` to make it work very well at the specific position. There may be some interesting insights from some of the bigger changes caused by moving it, but it seems moving it to LPM1 would be quite a heavy hammer. 

Exposing the unswitching logic directly and use that on demand in `IndVarSimplify` would likely be the most efficient approach. It also compared using a dedicated pass vs directly invoking functionality on demand in #83860 and directly invocation was noticeably faster. Should we go down this route?


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


More information about the llvm-commits mailing list