[Bug tree-optimization/115350] Missing optimzation: fold `n = std::min(f ? 0 : 3, -a)` to `n = -a`

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Mar 29 04:20:36 GMT 2026


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |15.0
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
      Known to fail|                            |14.3.0

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 15 by r15-5852-g999aad44aa86e6.

Which recongizes:
```
  _10 = _2 != 0;
  _5 = f_8(D) == 0;
  _11 = _5 | _10;
  if (_11 != 0)
    goto <bb 4>; [55.70%]
  else
    goto <bb 3>; [44.30%]

  <bb 3> [local count: 708669600]:

  <bb 4> [local count: 1073741824]:
  # _3 = PHI <0(3), _2(2)>
```
that _3 will just be _2.


More information about the Gcc-bugs mailing list