[Bug c++/83710] Unsigned with Signed multiplication followed by right shift
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Jan 6 09:40:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83710
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Chanpreet Singh from comment #4)
> (In reply to Andrew Pinski from comment #3)
> > For imull discussion see
> > https://stackoverflow.com/questions/42587607/why-is-imul-used-for-
> > multiplying-unsigned-numbers .
>
> I understand that. However, can you point to me what made the compiler
> choose shrl instruction over sarl?
Again: unsigned * int produces a type of unsigned. And then the shift is done
in unsigned type. See comment #1. imull is used for both signed and unsigned
multiply :).
More information about the Gcc-bugs
mailing list