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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-10-17
     Ever confirmed|0                           |1
            Summary|Regression: optimization    |[8/9/10/11 Regression]
                   |produces wrong code         |produces wrong code with
                   |                            |references to another field
          Component|c++                         |tree-optimization
           Keywords|                            |alias
   Target Milestone|---                         |8.5
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> This feels like an use after something goes out of scope.

It is not, there is some weird aliasing issue.

The IR looks like:
int foo(A) (struct A & restrict a)
{
  int _1;
  int & _2;
  int _3;
  int _4;
  int & _5;
  int _9;

  <bb 2> [0.00%]:
  _1 = *a_7(D).a;
  _2 = *a_7(D).b;
  _3 = *_2;
  _4 = _1 * _3;
  *a_7(D).a = _4;
  _5 = *a_7(D).b;
  _9 = *_5;
  return _9;

}

For some reason we think _5 cannot alias (*a_7(D)).a.  Most likely due to the
restict in the IR.  The restrict is there because a was passed by value rather
than reference but the way the ABI works, it is passed by a temp struct and we
expose this in the IR.  All things go down hill from there.

Reply via email to