public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/88603] optimization missed for saturation arithmetic add
[not found] <bug-88603-4@http.gcc.gnu.org/bugzilla/>
@ 2021-12-13 1:42 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; only message in thread
From: pinskia at gcc dot gnu.org @ 2021-12-13 1:42 UTC (permalink / raw)
To: gcc-bugs
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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-13 1:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-88603-4@http.gcc.gnu.org/bugzilla/>
2021-12-13 1:42 ` [Bug tree-optimization/88603] optimization missed for saturation arithmetic add pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).