public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Corey Minyard <minyard@acm.org>
To: gcc@gcc.gnu.org
Subject: Optimizations on long long multiply/divide on PowerPC32 don't work
Date: Fri, 07 Dec 2001 16:08:00 -0000	[thread overview]
Message-ID: <3C115A53.2070206@acm.org> (raw)

In yet another problem compiling the Linux kernel on PowerPC (32-bit) 
with the CVS tree, I'm running into a problem compiling something; the 
Linux kernel is expecting division of a long long by a constant value to 
be optimized and not call __divdi3, but the GCC compiler is not doing 
this.  The following program:

  long long t1(long long v)
  {
      return v / 512;
  }

will call __divdi3, even though the operation could be done much faster 
with shifts (and other stuff for handling negatives).  It turns out that 
the code to call __divdi3 is being emitted on the conversion to rtl, and 
the optimizations do not see this function call and handle it as a 
division, they just see it as a function call.  So no optimizations at 
all will be done on 64-bit multiplies and divides.  I consider this to 
be sub-optimal :-).

I can see four options to solve this problem:

  1) Add __divdi3 to the linux kernel.  I don't really think this is a 
good idea, and it shouldn't be required.
  2) Move the conversion of the division to the function call to the 
very last stages of the compiler.  IMHO, this is probably the best 
option, but it's a big job to implement, I think.
  3) Make the optimizations understand the function calls.  I don't even 
want to think about this one.
  4) Modify the tree conversions to do the optimizations there.  I have 
a patch that does this (and passes all regressions), because it was 
easy, but I consider it less optimal than option 2.

Any opinions on this?  I'll post my patch if the maintainers think 
option 4 is reasonable.

Thanks,

-Corey

             reply	other threads:[~2001-12-08  0:08 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-07 16:08 Corey Minyard [this message]
2001-12-07 17:08 ` Richard Henderson
2001-12-07 17:40   ` Corey Minyard
2001-12-09 23:29   ` Linus Torvalds
2001-12-10  1:15     ` Richard Henderson
2001-12-10  1:24       ` Richard Henderson
2001-12-10  2:40         ` Franz Sirl
2001-12-10  9:21           ` Linus Torvalds
2001-12-10 10:59             ` Franz Sirl
2001-12-10 11:11               ` Linus Torvalds
2001-12-10 11:31               ` Gabriel Paubert
2001-12-10 17:58                 ` Richard Henderson
2002-01-22  8:51         ` Franz Sirl
2002-01-22 12:04           ` Richard Henderson
2002-01-23  7:24             ` Gerald Pfeifer
2002-02-03 10:44               ` Franz Sirl
2001-12-10  9:15       ` Linus Torvalds
2001-12-10 13:03         ` Richard Henderson
2001-12-10 13:59           ` Linus Torvalds
2001-12-10  9:09     ` Paul Koning
2001-12-10 10:23       ` Linus Torvalds
2001-12-10 11:35         ` Optimizations on long long multiply/divide on PowerPC32 don't Joe Buck
2001-12-10 13:49           ` guerby
2001-12-10 14:08             ` Arnaud Charlet
2001-12-10 14:31               ` guerby
2001-12-10  9:09 ` Optimizations on long long multiply/divide on PowerPC32 don't work Christoph Hellwig
2001-12-07 18:28 mike stump

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=3C115A53.2070206@acm.org \
    --to=minyard@acm.org \
    --cc=gcc@gcc.gnu.org \
    /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).