[RFC] Make regclass optimistic about union register classes

Paolo Bonzini paolo.bonzini@lu.unisi.ch
Wed Jul 13 14:18:00 GMT 2005


This is a patch based on an old proposal by Jan Hubicka, which can be 
found at http://www.x86-64.org/lists/patches/msg00271.html.

This patch removes the need for all the '#' constraints in i386.md and 
possibly other MDs too.  When presented with an union class (e.g. 
FLOAT_INT_CLASS), regclass sees an alternative accepting FLOAT_CLASS and 
one accepting GENERAL_CLASS; in both cases he adds move cost for moving 
from SSE_FLOAT_CLASS to each of them: this is large because it is 
computed conservativly in case the pseudo ends up outside the 
destination class.  Then it decides randomly for one of the classes 
depending on the REGISTER_MOVE_COST differences. Thus we need to fake 
those superclass alternatives by always using r#fx or f#xr.

The patch fixes this by making regclass optimistic and not adding the 
cost when the alternate class is a superset of the preferred class.  It 
also fixes the cost computation to take into account properly 
may_move_in_cost or may_move_out_cost as in other parts of regclass.  is 
ommision in my regclass patches two years ago.

When originally submitted, rth did not approve the patch because it 
gives strange results in the lreg dump:

   main()
   {
       float b,c;
       asm volatile ("# %0 %1":"=&f,&r"(c):"f,r"(b));
       asm volatile ("# %0"::"f,r"(c));
   }

gives

   Register 58: GENERAL_REGS:0 FLOAT_REGS:0 FLOAT_INT_REGS:20000 MEM:6000
   Register 59: GENERAL_REGS:0 FLOAT_REGS:0 FLOAT_INT_REGS:10000 MEM:3000

   Register 58 pref FLOAT_INT_REGS or none
   Register 59 pref FLOAT_INT_REGS or none

It sure looks like GCC chooses the most expensive class, but actually 
FLOAT_INT_REGS is picked as the *union of the two classes with the 
minimum cost*, GENERAL_REGS and FLOAT_REGS.  I have then modified 
regclass to dump it like this:

   Register 58
    pref FLOAT_REGS + GENERAL_REGS = FLOAT_INT_REGS
    or none
   Register 59
    pref FLOAT_REGS + GENERAL_REGS = FLOAT_INT_REGS
    or none

I'll let a maintainer decide if this would be ok for stage3, so I post 
this as an RFC before bootstrapping and regtesting.  It does allow a 
significant cleanup of the # constraints in the fp templates, which also 
fixes some pessimizations with -mfpmath=sse.

Richard (Guenther), you may want test tramp3ds+libsse2 with this patch 
and something like http://www.x86-64.org/lists/patches/msg00272.html 
(the i386 constraint cleanup)?

Paolo
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: honza-regclass-2.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20050713/46a42b2d/attachment.ksh>


More information about the Gcc-patches mailing list