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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jamborm at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2020-05-29
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I see the cited -O3 code-gen with -O2 on trunk.  We expand from

foo (bool b)
{
  struct Optional D.2251;
  unsigned char _7;

  <bb 2> [local count: 1073741824]:
  if (b_2(D) != 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> [local count: 536870913]:
  D.2251.D.2152.value = 42;

  <bb 4> [local count: 1073741824]:
  # _7 = PHI <1(3), 0(2)>
  MEM <unsigned char> [(struct Optional *)&D.2251 + 4B] = _7;
  return D.2251;

where the main issue is likely we fail to elide D.2251 because of the
aggregate return (and us not exposing the ABI, etc.).

Note above D.2251 is partly initialized which makes it a bit more difficult
to optimize.  SRA might try to handle these cases by rematerializing the
aggregate just before the return.  We can then hope for RTL expansion
to do "magic".

Reply via email to