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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot 
gnu.org
                 CC|                            |pinskia at gcc dot gnu.org
   Last reconfirmed|                            |2025-10-03
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So the difference between GCC 14 and 15 is that GCC 14 would early inline:
  D.8563 = min_cmp<long int> (_2, _1);

But GCC 15 does not.

The difference is:
  MEM <char[8]> [(struct Res *)&D.8662 + 8B] = {};
  D.8662.M_min = y_5(D);
  D.8662.M_cmp._M_value = 1;

vs
  D.8854.M_min = y_5(D);
  D.8854.M_cmp._M_value = 1;

So zeroing the padding.

And the warning happens after inlining but before we can remove the (undefined)
memcmp call from being dead.

I wonder if we could optimize this:
```
  if (c$_M_value_21 == 1)
    goto <bb 6>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 6> :
  MEM <char[8]> [(struct Res *)&D.8662 + 8B] = {};
  D.8662.M_min = y_5(D);
  D.8662.M_cmp._M_value = 1;
  goto <bb 8>; [INV]

  <bb 7> :
  MEM <char[8]> [(struct Res *)&D.8662 + 8B] = {};
  D.8662.M_min = x_3(D);
  D.8662.M_cmp._M_value = c$_M_value_21;

  <bb 8> :
```

Into:

  if (c$_M_value_21 == 1)
    goto <bb 6>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 6> :
  MEM <char[8]> [(struct Res *)&D.8662 + 8B] = {};
  goto <bb 8>; [INV]

  <bb 7> :
  MEM <char[8]> [(struct Res *)&D.8662 + 8B] = {};

  <bb 8> :
  _9 = PHI<x_3(D)(7), y_5(D)(6)>
  D.8662.M_min = _9;
  D.8662.M_cmp._M_value = c$_M_value_21;

In phiopt1, it might be better.

Sink is able to do it too:
/app/example.cpp:13:17: optimized: sinking common stores to
D.8662.M_cmp._M_value
/app/example.cpp:13:17: optimized: sinking common stores to D.8662.M_min
/app/example.cpp:13:17: optimized: sinking common stores with same value to MEM
<char[7]> [(struct Res *)&D.8662 + 9B]

But cselim does not know how to handle the {} I think.
In this case cselim should be able to handle it even without DR. Let me see if
I can improve cselim/cselim light in phiopt1 to handle it.

Because I think that will fixup the early inlining issue.

Reply via email to