public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: Hans Petter Selasky <hselasky@c2i.net>
To: Graham Stott <graham.stott@btinternet.com>
Cc: gcc-bugs@gcc.gnu.org
Subject: Re: GCC has problems with 64-bit multiplication
Date: Thu, 08 Feb 2007 16:21:00 -0000	[thread overview]
Message-ID: <200702081616.15990.hselasky@c2i.net> (raw)
In-Reply-To: <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


  reply	other threads:[~2007-02-08 16:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-08 14:03 Hans Petter Selasky
2007-02-08 15:03 ` Graham Stott
2007-02-08 16:21   ` Hans Petter Selasky [this message]
2007-02-26 14:35   ` Hans Petter Selasky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200702081616.15990.hselasky@c2i.net \
    --to=hselasky@c2i.net \
    --cc=gcc-bugs@gcc.gnu.org \
    --cc=graham.stott@btinternet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).