[PATCH] RegAllocGreedy: Improve live interval order in ReverseLocal mode
Andrew Trick
atrick at apple.com
Thu Mar 26 09:58:17 PDT 2015
> On Mar 25, 2015, at 8:01 PM, Matthias Braun <matze at braunis.de> wrote:
>
> Hi qcolombet, atrick,
>
> 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).
You’re absolutely right. The code as-is was intentional though, and known not to give optimal colorings. That heuristic is not about coloring but about compile time as the comment above attempts to explain.
Andy
>
> No testcase as none of the (in tree) targets use reverse order mode.
>
> http://reviews.llvm.org/D8625
>
> Files:
> lib/CodeGen/RegAllocGreedy.cpp
>
> Index: lib/CodeGen/RegAllocGreedy.cpp
> ===================================================================
> --- lib/CodeGen/RegAllocGreedy.cpp
> +++ lib/CodeGen/RegAllocGreedy.cpp
> @@ -552,7 +552,7 @@
> // Allocating bottom up may allow many short LRGs to be assigned first
> // to one of the cheap registers. This could be much faster for very
> // large blocks on targets with many physical registers.
> - Prio = Indexes->getZeroIndex().getInstrDistance(LI->beginIndex());
> + Prio = Indexes->getZeroIndex().getInstrDistance(LI->endIndex());
> }
> }
> else {
>
> EMAIL PREFERENCES
> http://reviews.llvm.org/settings/panel/emailpreferences/
> <D8625.22695.patch>
More information about the llvm-commits
mailing list