[lno] missing optimization

Dale Johannesen dalej@apple.com
Sun May 16 17:30:00 GMT 2004


Currently the tree loop optimizer is overconservative about aliasing in 
invariant detection.
For example:

int x; int y;
int foo() {
  int i;
  for ( i=0; i<10; i++)
    y += x*x;
}
struct { int x; int y; } global;
int foo2() {
  int i;
  for ( i=0; i<10; i++)
    global.y += global.x*global.x;
}
The loop bodies of both functions ought to have the same code, and they 
do on mainline.
lno doesn't figure out that global.x and global.y don't interfere.  It 
looks at SSA_NAME_DEF_STMT,
but that refers to a PHI that applies to the entire struct.  I see that 
breaking the struct into
scalars at an earlier stage would fix this.  Is there a better way?




More information about the Gcc mailing list