This is an archive of the discontinued LLVM Phabricator instance.

RegAllocGreedy: Improve live interval order in ReverseLocal mode
ClosedPublic

Authored by MatzeB on Mar 25 2015, 8:01 PM.

Details

Summary

When allocating live intervals in linear order and all of them are local
to a single basic block you get an optimal coloring. This is also true
if you reverse the order, but it is not true if you sort live ranges
beginnings in reverse order, change to sort live range endings in
reverse order. Take the following live ranges for example:

|---| |--------|

They get colored suboptimally with 3 registers if you sort the live range
starting points in reverse order (but optimally with live range begins in order,
or live range ends in reverse order).

No testcase as none of the (in tree) targets use reverse order mode.

Diff Detail

Repository
rL LLVM

Event Timeline

MatzeB updated this revision to Diff 22695.Mar 25 2015, 8:01 PM
MatzeB retitled this revision from to RegAllocGreedy: Improve live interval order in ReverseLocal mode.
MatzeB updated this object.
MatzeB added reviewers: qcolombet, atrick.
MatzeB added a subscriber: Unknown Object (MLST).
MatzeB updated this revision to Diff 22696.Mar 25 2015, 8:10 PM
  • RegAllocGreedy: Allow target to specify register class ordering.

Please ignore the last update, it should go into an own revision, but arc diff attached it to the last one in my local branch...

qcolombet accepted this revision.Mar 26 2015, 9:53 AM
qcolombet edited edge metadata.

Hi Matthias,

Nice catch!

When you commit, please detail the example by naming the interval and giving the different orders (non optimal, what we have now, and optimal).
The current explanations are fine, but it took a bit of thought to reconstruct why it is happening and I prefer no-brainer comment :).

Did you see any differences for in-tree targets on the LLVM test-suite?

Thanks,
-Quentin

This revision is now accepted and ready to land.Mar 26 2015, 9:53 AM
This revision was automatically updated to reflect the committed changes.