[Bug tree-optimization/124097] Transform if (a[i] > 0) sum += a[i] into sum += max (0, a[i]) when vectorising

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Feb 13 18:34:28 GMT 2026


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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Maybe an easy way of implementing this is to add a match pattern for:
 _15 = _4 > 0.0;
  _ifc__29 = .COND_ADD (_15, sum_14, _4, sum_14);


Which converts that into:
  _ifc__29 = MAX_EXPR <_4, 0.0>;
  _30 = sum_14 + _ifc__29;


More information about the Gcc-bugs mailing list