v6m cores only have a limited number of registers available. Unrolling can mean we spend more on stack spills and reloads than we save from the unrolling. This patch adds an extra heuristic to puts a limit on unroll count for loops with multiple live out values, as measured from the LCSSA phi nodes.
I would expect that most loops have a single exit, but the code above does allow (at most) 2 exit.
From those I took the maximum of the number of liveouts as a rough heuristic, as I would expect the liveouts to be the same in many cases for multi-exit loops, and it probably doesn't want to count them twice.
Ah yes, I now see:
if (ExitingBlocks.size() > 2) return;
above and also that the maximum is taken, thanks.
One nit/question about the test case then, would it be useful to have a test and loop with 2 exit blocks?