This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GCC's new register allocator


Hi All,
I have a query regarding the new register allocator implemented by 
"Michael Matz".
Consider the following code fragment

void foo(int i, int *a, int *p) {
        int x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14;
        x1=a[i];
        x2=a[i+1];
        x3=a[i+2];
        x4=a[i+3];
        x5=a[i+4];
        x6=a[i+5];
        x7=a[i+6];
        x8=a[i+7];
        x9=a[i+8];
        x10=a[i+9];
        x11=a[i+10];
        x12=a[i+11];
        x13=a[i+12];
        x14=a[i+13];
        *p=99;
        a[i]=x14;
        a[i+1]=x13;
        a[i+2]=x12;
        a[i+3]=x11;
        a[i+4]=x10;
        a[i+5]=x9;
        a[i+6]=x8;
        a[i+7]=x7;
        a[i+8]=x6;
        a[i+9]=x5;
        a[i+10]=x4;
        a[i+11]=x3;
        a[i+12]=x2;
        a[i+13]=x1;
}

This code after running on x86, allocates
web 0    (pseudo 88 -- corresponding to x14)    to      color 1
web 17  (pseudo 87 -- corresponding to x13)     to      color 5
web 16   (pseudo 86 -- corresponding to x12)    to      color 2
web 15   (pseudo 85 -- corresponding to x11)    to      color 3
web 14   (pseudo 84 -- corresponding to x10)    to      color 4
web 13 to web 4 (corresponding to x1-x9) all get a color 0  -- which I 
assume have been spilled as they use the "an_usable_color" --  Why are the 
spilled webs get an_usable_color which happens to be the first free usable 
color in the FIXED_REGISTER set?

Looking at the i386.h file, I find set of GENERAL_REGS class can use 
%eax,%ebx,%ecx,%edx,%esi, %edi,%ebp,%esp and %r8-%r15.
As per my understanding  %ebx, %ecx, %edx, %esi, and %edi are used for 
register allocation and others are used for special purpose stack and base 
pointers and %r8-15 are not usable due to the contraint in 
FIXED_REGISTERS.

Does this mean we can not use more than 5 registers for integer variables 
?  If not, then how can I modify the i386.h file to increase the number of 
usable regsiters for integer variables?


Am I missing anything?

regards,
Raj


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]