This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[lno] missing optimization
- From: Dale Johannesen <dalej at apple dot com>
- To: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Cc: gcc at gnu dot org
- Date: Sun, 16 May 2004 10:26:42 -0700
- Subject: [lno] missing optimization
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?