[Bug tree-optimization/126678] Defaulted operator== on an iota_view value type makes the enclosing loop be estimated ~7x colder than an identical hand-written operator==

"pinskia at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.