This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: GCC has problems with 64-bit multiplication
- From: Hans Petter Selasky <hselasky at c2i dot net>
- To: Graham Stott <graham dot stott at btinternet dot com>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 8 Feb 2007 16:16:15 +0100
- Subject: Re: GCC has problems with 64-bit multiplication
- References: <20070208150235.80441.qmail@web86107.mail.ird.yahoo.com>
On Thursday 08 February 2007 16:02, Graham Stott wrote:
> All,
>
> Not a bug in GCC the result is correct as you've only asked for a 32-bit
> multiply.
Ok, thanks. But really I don't want to do "((int64_t)a) * b", which I know
works, hence that is very much slower than "a * b" on intel processors, hence
the "mull" instruction will be used instead of "imul".
I found the following option by googling:
-mwide-multiply multiplies of 32 bits are 64
Is there an __attribute__() that I can use that will enable this for one
multiplication, and not all ? Or something similar ?
>
> --- Hans Petter Selasky <hselasky@c2i.net> wrote:
> > Test program:
> >
> > #include <stdio.h>
> > #include <sys/types.h>
> >
> > int main() {
> >
> > int32_t a = 0x40000000;
> > int16_t b = 0x4000;
> > int64_t c = a * b;
>
> ^^^^^ this is a 32-bit multiply with the result
> widened to 64-bit,
>
> > printf("0x%016llx\n", c);
> >
> > return 0;
> > }
--HPS