RegAllocGreedy: Improve live interval order in ReverseLocal mode
authorMatthias Braun <matze@braunis.de>
Tue, 31 Mar 2015 19:57:49 +0000 (19:57 +0000)
committerMatthias Braun <matze@braunis.de>
Tue, 31 Mar 2015 19:57:49 +0000 (19:57 +0000)
commit3f1ec42ec73d61eceddfca6071695431b50b78ed
treeb1f4a5e16d53ce11118b00bb9c64ff000277786b
parentfcadd6d973524cc82f8bc282b3f4102c56f89c03
RegAllocGreedy: Improve live interval order in ReverseLocal mode

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).

Apparently the previous strategy was intentional because of allocation
time considerations. I am having a hard time replicating these effects,
while I see substantial improvements in allocation quality with this
change.

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

Differential Revision: http://reviews.llvm.org/D8625

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233742 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/RegAllocGreedy.cpp