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]

bug in aliasing


It seems gcc does not move an invariant local array element out of the 
loop. In the following test "str[2]" is
not moved out of the loop. I went through the interference analysis 
routines and it seems it assumes a store
into any stack variable (m1 array in this case) will interfere with all 
variables allocated on stack,  such as str
in this case.

I was going to find a solution for this problem, but I thought I  would 
ask the experts in the community before I take
a shot at it.

Thanks
Reza Yazdani

Apple Computer


void test()
{
   int str[27];
   int m1[100];
   int k3=0;
   int i;

     for(i='A';i<'Z';i++)
     {
       m1[k3++]=str[2];
     }
}

The assembly code is:

.text
         .align 2
         .globl _test
_test:
         li r2,25
         stwu r1,-560(r1)
         mtctr r2
         li r11,0
         addi r10,r1,144
L9:
         lwz r3,40(r1)       <-- loop invariant
         slwi r2,r11,2
         addi r11,r11,1
         stwx r3,r10,r2
         bdnz L9
         addi r1,r1,560
         blr


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