aggregate alias anomaly

Andrew Pinski pinskia@physics.uc.edu
Thu Feb 19 07:21:00 GMT 2004


On Feb 18, 2004, at 21:15, Jeff Sturm wrote:

> Given:
>
> struct X {int x;};
> struct Y {int y;};
>
> int f(struct X *x, struct Y *y) {
>         x->x = 0;
>         y->y = 1;
>         return x->x;
> }

Yes this is a known problem with the current RTL aliasing sets.
To make even matters worse, the following programs is not optimized 
either
on any compiler, even the tree-ssa, even after my patch
not to lower &x->x into (int*)(x), but it does work points-to,
with or without the patch:

struct X {int x;};
struct Y {int y;};

int f(struct X *x, struct Y *y) {
int *restrict  xx = & x->x;
int *restrict  yy = & y->y;
         *xx = 0;
         *yy = 1;
         return *xx;
}

The following code works on RTL on every recent compiler though:
struct X {int x;};
struct Y {int y;};

int f(struct X *__restrict x, struct Y * __restrict y) {
         x->x = 0;
         y->y = 1;
         return x->x;
}

Thanks,
Andrew Pinski



More information about the Gcc mailing list