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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So this is IPA modref in action.

  loads:
      Base 0: alias set 1
        Ref 0: alias set 1
          access: Parm 0 param offset:0 offset:0 size:6 max_size:6
  stores:
      Base 0: alias set 0
        Ref 0: alias set 0
          access: Parm 1 param offset:0 offset:0 size:-1 max_size:64



So we know that e only does a store to the second argument (via aliasing set 0
which is the is the root of all aliasing sets) and loads from the first
argument with an aliasing set of 1( in this case it is the aliasing set that is
contained for struct c).

So when DSE comes a long, it removes the store to j as it not used by the e
function as it is in the non-conflicting aliasing set of e.

Note casting does not change aliasing sets even.

In that main could have been:
```
    int main(void) {
      struct c t = {0};
      uint64_t k;
      e((uint64_t*)&t, &k);
      if (k)
        __builtin_trap();

      return 0;
    }
```
And that would have been valid and well defined code.

Reply via email to