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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org
   Last reconfirmed|                            |2021-04-13
     Ever confirmed|0                           |1
            Version|unknown                     |11.0
           Keywords|                            |alias, missed-optimization
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The difference is WRT -fstrict-aliasing which forces us to keep a redundant
store:

   b = 0;
   c = 0;
   d.1_2 = d;
   _3 = *d.1_2;
   f = _3;
+  *d.1_2 = _3;
   b.4_10 = b;
   if (b.4_10 == 2)

and this store prevents us from CSEing the load from b with the earlier store
from zero to simplify the test because d could alias b.  It looks like
we fail to make the size argument but eventually because of possible
interposition.  We could also figure the stores redundancy during
disambiguation and ignore it based on that fact.

There is code to do the size based disambiguation but it's fent off via
an earlier

  /* If the alias set for a pointer access is zero all bets are off.  */
  if (base1_alias_set == 0 || base2_alias_set == 0)
    return true;

it's also guarded by -fstrict-aliasing for reasons I do not remember.
The base2_alias_set check was added by Honza recently.  The size check
uses not the access size but the possibly larger access TBAA type size
determining the dynamic type of the indirectly addressed object, we can
probably improve this and use the access size for the !tbaa case here.

Reply via email to