32 x 32 -> 64 bit widening multiply on x86_64

Ian Lance Taylor iant@google.com
Tue Nov 11 15:48:00 GMT 2008

"Mark Dickinson" <dickinsm@gmail.com> writes:

> If I'm not mistaken, that imulq is a 64 x 64 -> 64 bit multiply; this
> seems inefficient, when a 32 x 32 -> 64 bit multiply ought to be
> good enough.  Is there a good reason for having a 64-bit multiply
> here?  Or is gcc just not in a good position to make this kind
> of optimization?

The problem with the 32 x 32 -> 64 bit widening multiply in 64-bit
mode is that it generates the result as two separate 32-bit values in
different registers.  In order to use the 64-bit value, gcc would have
to generate code to reassemble the two registers into one.  On balance
it's normally preferable to simply use the 64 x 64 -> 64 multiply.


More information about the Gcc-help mailing list