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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
                 CC|                            |pinskia at gcc dot gnu.org
         Depends on|                            |126043
          Component|c++                         |tree-optimization
   Last reconfirmed|                            |2026-08-06
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #2 from Drea Pinski <pinskia at gcc dot gnu.org> ---
Non default:
  _16 = (short int) _14;
  if (_16 != 0)
    goto <bb 3>; [89.00%]
  else
    goto <bb 12>; [11.00%]

vs defaulted
  <bb 2> [local count: 536870912]:
  _14 = MEM[(const struct S *)this_12(D)].n;
  _16 = (short int) _14;
  if (_16 == 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

And that comes because of this:

  if (_1 == _2)
    goto <bb 4>; [INV]
  else
    goto <bb 3>; [INV]

  <bb 3> :
  // predicted unlikely by early return (on trees) predictor.

  <bb 4> :
  # _3 = PHI <0(3), 1(2)>
is not simplified into just return.


Then the jump threading. uses the 50/50 from this one.

So this is basically PR 126043.
Maybe I will go and fix that ...


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126043
[Bug 126043] early phiopt should allow CMP, (cast)CMP, -(cast)CMP

Reply via email to