LoopSimplify : why to separate a loop with multiple backedges into a nested loop ?

Hello,

LoopSimplify try to separate a loop with multiple backedges into a
nested loop (an outer loop and an inner loop).
Naturally, this kind of a loop corresponds to a single loop in source
code. I can see this could be useful for cases described in the
comments in lib/Transforms/Utils/LoopSimplify.cpp, which looks like a
corner case. For most cases,
how does this help ?

Junjie

It helps later passes optimize the inner loop. For
example, an expression may be loop-invariant in the inner loop
but not in the outer loop. Separating them into two loops
allows LICM to hoist the value out of the inner loop, for
example.

LLVM doesn't have all that many loop optimizations currently; if it
had more, there would be more cases where this canonicalization
could help.

Dan