[llvm-commits] [patch] Improve register coalescing
Jakob Stoklund Olesen
stoklund at 2pi.dk
Thu Jun 30 14:47:45 PDT 2011
On Jun 30, 2011, at 2:36 PM, Rafael Ávila de Espíndola wrote:
> An updated copy is attached.
LGTM!
>> Would it be possible to do more complete value-based checking? For
>> example, you don't handle this:
>>
>> X = Y A = X B = Y
>
> but it doesn't handle this, we would have to coalesce X and Y first (which might fail).
That's OK, this is a good start. The most common case is probably phi-elim fallout anyway.
> The real solution I think would be to turn the coalescing algorithm
> upside down: instead of trying to merge registers one pair at a time,
> start by assuming that every copy related register can be merged and
> try to show it cannot.
That sounds hard to get right.
> In the above example, A, B, X, Y would be be in one set initially.
> If we then show that X and Y cannot merge, we would have the sets
> {A, B, X} and {A, B, Y}. If no further conflicts exist, we can choose
> to merge A, B and X or A, B and Y.
>
> An intermediate option is to look for copy chains. From
>
> A = X
> B = Y
>
> we follow the definitions of X and Y until we find a non copy. It
> would work on the above example, but fail in
>
> BB1:
> X = B
> Y = A
>
> BB2:
> A = X
> B = Y
>
> A and B can be merged if X and Y can be merged and X and Y can be
> merge if A and B can be merged.
I think we already detect and remove this kind of PHI loops?
/jakob
More information about the llvm-commits
mailing list