https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121881

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #3)
> You can't generally do this when alias-sets differ (unless one is zero,
> which you can then pick).  See the various redundant store issues - you need
> to second guess all following reads valid with either version and "common"
> to a variant valid for all of them (including thinking about TBAA "paths"). 
> Using alias-set zero when !operand_equal_p would be a possibility.  We do
> have a "compatibility" predicate, used for example by ICF.

Right the aliasing set is thing that worries me the most.
To begin I was thinking about using reference_alias_ptr_type and seeing those 2
types are the same.

Though in the original case we should be able to use "int*" as the alias_ptr
here I think. Because it is subset of `struct s1*` aliasing set . (zero is
always a subset).

Here is more complex example:
```
struct s2
{
  int t;
};

struct s1
{
  struct s2 t;
};

void f(int a, int b, struct s1 *t)
{
  struct s2 *c1 = &t->t;
  if (a)
    t->t.t = b;
  else
    c1->t = b;
}
```

The IR is:
```
  t_2(D)->t.t = b_6(D);
...
  MEM[(struct s2 *)t_2(D)].t = b_6(D);
```
Using `struct s2*` as the common aliasing type should be ok I think.

Reply via email to