[llvm-commits] [PATCH] Don't -join-cross-class-copies of physical and virtual registers

Jakob Stoklund Olesen stoklund at 2pi.dk
Wed Apr 22 22:40:11 PDT 2009


When SimpleRegisterCoalescing::JoinCopy is trying to coalesce a  
physical register with a virtual register, differingRegisterClasses  
returns true exactly when the physical register does not belong to the  
register class of the virtual register.

In this case it would be illegal to coalesce. The virtual register  
regclass is the set of legal registers for the instructions using it.  
A physical register outside the regclass could lead to illegal  
instruction operands.

This happens frequently when using -join-cross-class-copies with my  
Blackfin backend. It think it might not happen for X86 because the  
only instruction with particular regclass requirements is  
EXTRACT_SUBREG, and that is being removed by the coalescer.

Unfortunately I have not been able to produce an X86 test case. I have  
one for Blackfin.

The attached patch will bail out early when attempting a cross class  
join between a physical and a virtual register. It also removes a bit  
of logic that is no longer needed when both registers are known to be  
virtual.

The removed code includes the obvious typo in "if (!SrcIsPhys && ! 
SrcIsPhys)"

-------------- next part --------------
A non-text attachment was scrubbed...
Name: coalesce-phys-virt.patch
Type: application/octet-stream
Size: 3381 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090423/111f6824/attachment.obj>
-------------- next part --------------



More information about the llvm-commits mailing list