This is the mail archive of the 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]
Other format: [Raw text]

[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.


Attachment: mustdef.diff
Description: Text document

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