[Bug target/83210] __builtin_mul_overflow() generates suboptimal code when exactly one argument is the constant 2

lh_mouse at 126 dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 29 10:02:00 GMT 2017


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

--- Comment #4 from Liu Hao <lh_mouse at 126 dot com> ---
(In reply to Andrew Pinski from comment #2)
> (res >> 3) != src;
> 
> Why not just (src>>(sizeof (res)*8-3))!=0.
> 
> Seems shorter and might be faster.

What if the second operand is not a power of 2? `(res * 5 / 5 != src)` will
always work, but bitwise shifting might not.


More information about the Gcc-bugs mailing list