This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: 32 x 32 -> 64 bit widening multiply on x86_64
- From: Ian Lance Taylor <iant at google dot com>
- To: "Mark Dickinson" <dickinsm at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 11 Nov 2008 07:27:05 -0800
- Subject: Re: 32 x 32 -> 64 bit widening multiply on x86_64
- References: <5c6f2a5d0811110208u5161fa10s2e9bea92f117e8b3@mail.gmail.com>
"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.
Ian