This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/82858] __builtin_add_overflow() generates suboptimal code with unsigned types on x86
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 06 Nov 2017 12:33:23 +0000
- Subject: [Bug target/82858] __builtin_add_overflow() generates suboptimal code with unsigned types on x86
- Auto-submitted: auto-generated
- References: <bug-82858-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82858
--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> ---
unsigned c;
unsigned d = __builtin_add_overflow(a, b, &c)?-1:0;
return c|d;
gives the expected asm. Ideally phiopt would recognize a saturing add pattern,
but we have nothing to model it in gimple. We could turn it into the branchless
BIT_IOR form though.
(the problem isn't with __builtin_add_overflow but with what comes afterwards)