[Bug target/82858] __builtin_add_overflow() generates suboptimal code with unsigned types on x86
trippels at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Nov 6 12:27:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82858
--- Comment #3 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
(In reply to Liu Hao from comment #2)
> Trunk on <https://gcc.godbolt.org/> produces the following code:
>
> ```
> saturated_add(unsigned int, unsigned int):
> add edi, esi
> mov eax, -1
> cmovnc eax, edi
> ret
> ```
>
> Condition moves are however, in my opinion, nothing better than branches, or
> they could be something worse: <http://yarchive.net/comp/linux/cmov.html>
Linus is talking about the Pentium 4. Hardware has evolved since then.
On today's CPUs CMOV is fine.
More information about the Gcc-bugs
mailing list