This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[sa]: Make component references must-defs when possible
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 20 Dec 2004 12:24:27 -0500 (EST)
- Subject: [sa]: Make component references must-defs when possible
This patch fixes the long standing problem in tree-ssa that we would
generate different code for the following two loops, and have extra
needless stores in the second loop:
int x; int y;
struct { int x; int y; } global;
int foo() {
int i;
for ( i=0; i<10; i++)
y += x*x;
for ( i=0; i<10; i++)
global.y += global.x*global.x;
}
This was because even with the previous patch to make the component refs
accessing different fields into vuses/v_may_defs of different variables,
we still couldn't eliminate the needless stores because they were only
may-defs, not must-defs.
The attached patch makes component-refs into must-defs when possible,
resulting in a lot more component accesses being eliminated.
With it, the code produced for the above two loops is identical, having
the same number of loads and stores from the various variables.
We currently don't make them must-defs when we have overlaps or array
references in the component reference.
This is conservatively correct. We could be a bit more aggressive than we
are now.
For the case of overlaps, we could do must-defs for every fake variable
that is completely covered by the access. For array refs, we could do it
if the array reference was to a constant offset.
Bootstrapped and regtested on i686-pc-linux-gnu. Committed to structure
aliasing branch.
--DanAttachment:
mustdef.diff
Description: Text document