https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88603
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this gives the best code really:
uint32_t saturation_add1(uint32_t a, uint32_t b)
{
uint32_t t;
if (__builtin_add_overflow (a, b, &t))
return UINT32_MAX;
return t;
}
That is recognizing:
_1 = (long unsigned int) a_4(D);
_2 = (long unsigned int) b_5(D);
tmp_6 = _1 + _2;
if (tmp_6 > 4294967295)
As:
_6 = .ADD_OVERFLOW (a_4(D), b_5(D));
_2 = IMAGPART_EXPR <_6>;
if (_2 != 0)