public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Optimizations on long long multiply/divide on PowerPC32 don't work
@ 2001-12-07 16:08 Corey Minyard
  2001-12-07 17:08 ` Richard Henderson
  2001-12-10  9:09 ` Optimizations on long long multiply/divide on PowerPC32 don't work Christoph Hellwig
  0 siblings, 2 replies; 27+ messages in thread
From: Corey Minyard @ 2001-12-07 16:08 UTC (permalink / raw)
  To: gcc

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

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: Optimizations on long long multiply/divide on PowerPC32 don't work
@ 2001-12-07 18:28 mike stump
  0 siblings, 0 replies; 27+ messages in thread
From: mike stump @ 2001-12-07 18:28 UTC (permalink / raw)
  To: minyard, rth; +Cc: gcc

> Date: Fri, 7 Dec 2001 16:49:04 -0800
> From: Richard Henderson <rth@redhat.com>
> To: Corey Minyard <minyard@acm.org>
> Cc: gcc@gcc.gnu.org

> On Fri, Dec 07, 2001 at 06:09:55PM -0600, Corey Minyard wrote:
> >   1) Add __divdi3 to the linux kernel.  I don't really think this is a 
> > good idea, and it shouldn't be required.

> Yes it should.  I've long considered it a bug that Linux
> didn't link against libgcc.

Speaking as someone that has a kernel and gcc, let me say, that of
course one wants to link against libgcc.a and libstdc++.a.  In fact,
one might even want to go out of their way to include large swaths of
the libraries even though there are no references to them, just so
that dynamically loaded code can resolve against it.

This is the recommendation of the gcc folks, and if folks don't want
to follow it, that is their problem, and they will have to deal with
it by themselves, as they created it.

I've been witnessing these problems first hand for the last 4 years,
and I know it is the right solution.

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2002-02-03 18:39 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-07 16:08 Optimizations on long long multiply/divide on PowerPC32 don't work Corey Minyard
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

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).