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

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 13 10:33:06 PDT 2024


preames wrote:

Drive by comment on alternatives...

The loop pass manger already supports requeueing a loop.  This is done inside LPM1 today by e.g. both unswitch and rotate.  This can cause significant compile time problems of its own - which is how I noticed it again recently.

One option here would be to either a) requeue the loop in IndVarSimplify if a loop invariant condition is exposed as part of LPM2 (this would still require adding unswitch to LPM2), or b) update indvars to preserve memory ssa and move it to LPM1 which can already iterate.

As an aside, starting with trivial only unswitching is probably much safer.  I saw a really nasty compile time problem recently caused by the requeue interaction with non-trivial unswitch.  

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


More information about the llvm-commits mailing list