This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Limit v6m unrolling with multiple live outs

Authored by dmgreen on Jun 21 2021, 11:12 AM.



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.

Diff Detail

Event Timeline

dmgreen created this revision.Jun 21 2021, 11:12 AM
dmgreen requested review of this revision.Jun 21 2021, 11:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2021, 11:12 AM
SjoerdMeijer added inline comments.Jun 22 2021, 3:19 AM

In the long run, all of this should be being learnt by a machine.



I was wondering if this is right. I.e., we are not e.g. accumulating the exit values, or taking a maximum, or something like that, if I am not mistaken.

dmgreen added inline comments.Jun 22 2021, 6:37 AM

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.

SjoerdMeijer added inline comments.Jun 22 2021, 6:52 AM

Ah yes, I now see:

if (ExitingBlocks.size() > 2)

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?

dmgreen updated this revision to Diff 353718.Jun 22 2021, 11:09 AM

Added a test with multiple exits (which was a bit hard to get past other profitability checks).

SjoerdMeijer accepted this revision.Jun 23 2021, 6:28 AM

Thanks! And this heuristic looks sensible to me, so LGTM.

This revision is now accepted and ready to land.Jun 23 2021, 6:28 AM
This revision was automatically updated to reflect the committed changes.