From mboxrd@z Thu Jan 1 00:00:00 1970 From: reza@apple.com To: gcc@gcc.gnu.org Cc: Reza Yazdani Subject: bug in aliasing Date: Wed, 10 Oct 2001 15:56:00 -0000 Message-id: <200110102256.PAA13681@scv1.apple.com> X-SW-Source: 2001-10/msg00689.html 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