[Bug middle-end/95669] -O3 generates more complicated code to return 8-byte struct of zeros, sometimes

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 15 06:55:15 GMT 2020


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |middle-end
             Target|                            |x86_64-*-*
   Last reconfirmed|                            |2020-06-15
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
with 'dummy' and the implicit zero initialization of it we retain

  <bb 2> [local count: 1073741824]:
  if (a_3(D) < b_4(D)) 
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> [local count: 536870913]:
  D.2350 = {};
  goto <bb 5>; [100.00%]

  <bb 4> [local count: 536870913]:
  _1 = a_3(D) * b_4(D);
  D.2350.val = _1;
  MEM <unsigned int> [(void *)&D.2350 + 4B] = 1;

  <bb 5> [local count: 1073741824]:
  return D.2350;

wich generates straigt-forward code while with 'dummy' elided we manage
to completely scalarize things and do

  <bb 2> [local count: 1073741824]:
  if (a_3(D) < b_4(D)) 
    goto <bb 4>; [50.00%]
  else
    goto <bb 3>; [50.00%]

  <bb 3> [local count: 536870913]:
  _1 = a_3(D) * b_4(D);

  <bb 4> [local count: 1073741824]:
  # cstore_11 = PHI <_1(3), 0(2)>
  # cstore_10 = PHI <1(3), 0(2)>
  D.2349.ok = cstore_10;
  D.2349.val = cstore_11;
  return D.2349;

which is basically two conditional moves we expand via strange bit
shufflings because D.2349 (struct res) is assigned a register.


More information about the Gcc-bugs mailing list