[llvm-commits] [llvm] r108118 - /llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Sun Jul 18 18:33:36 PDT 2010


On Jul 18, 2010, at 12:39 PM, Rafael Espindola wrote:

> On 18 July 2010 05:09, Lang Hames <lhames at gmail.com> wrote:
>>> I think that the test for virtual registers is more strict than it needs
>>> to be,
>>> it should be possible to coalesce two virtual registers the class of one
>>> is a subclass of the other.
>> 
>> That certainly sounds safe if the destination class is a subclass of the
>> source class. I assume going the other way is dangerous, in that it could
>> leave junk in the non-aliased portion of the super-register?
> 
> Note that this *subclass*, not *subregister". I don't think in general
> it is safe to coalesce if the two classes have different value types
> (which is an interesting limitation now that I think of it).

It is. Value types are only used during instruction selection. They don't matter after that. The type-specific operations are encoded in the instructions, compare padd, addps, addpd.

> Lets say we have two virtual registers V0 and V1. The first one is in
> class S1 with physical registers R0, R1 and R2. The second one is in
> class S2 with registers R0, R1 and R3. If we coalesce V0 and V1, what
> physical registers can be used for the coalesced reg? R0 and R1.

Right. We may have to settle for a smaller register class if none exists containing exactly R0 and R1. getCommonSubClass will find the one you need.

> In general, we should be able to coalesce two virtual registers if
> they have the same value types and the resulting reg class is in the
> intersection of the two original ones.

Correct, except the value types don't matter. For instance, it is possible to coalesce two registers of classes RFP32 and RFP64. The resulting register will be RFP64 because that class has the larger spill size.

TableGen says that RFP64 is a subclass of RFP32 so this will work.

> I wonder what would it take to be able to coalesce, for example, a
> vector and a fp virtual register. Just moving the value type out of
> the register class and into the individual operations?

It already is.

The CoalescerPair class in RegisterCoalescing.cpp has all the gory details determining if a copy can be coalesced and what the resulting register class should be. 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100718/c83050aa/attachment.bin>


More information about the llvm-commits mailing list