[Bug tree-optimization/101641] New: Bogus redundant store removal

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jul 27 12:03:11 GMT 2021


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

            Bug ID: 101641
           Summary: Bogus redundant store removal
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

union u {
  long x;
  long long y;
};

__attribute__((noinline,noclone))
long test(long *px, long long *py, union u *pu)
{
  *px = 0;
  *py = 1;

  long xy = pu->y;
  pu->x = xy;

  return *px;
}

int main ()
{    
  union u u;
  if (test (&u.x, &u.y, &u) != 1)
    __builtin_abort ();
  return 0;
}

is miscompiled at -O2+ as FRE removes the seemingly redundant store to
pu->x but that's needed to make the read via *px pick up the value stored
via *py = 1 rather than (correctly) disambiguating against that and
running into *px = 0.


More information about the Gcc-bugs mailing list