public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* frexp function misoptimization
@ 2008-03-07 12:20 Jeremy Sanders
  2008-03-08  2:18 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Jeremy Sanders @ 2008-03-07 12:20 UTC (permalink / raw)
  To: gcc-help

I notice on x86_64 Linux with gcc-4.1.2, that if I make a call to frexp()
from math.h, this function is not inlined in the assembly output
(with -O2). I've tried -ffast-math as well.

As this function could be trivially inlined (it's just a matter of getting
the correct bits from the stored number), is this a gcc misoptimization or
is glibc the culprit?

Here's a sample program:

---------------------------
#include <math.h>

int main()
{
  double x = 1.;
  int i;

  x = frexp(x, &i);
  return 0;
}
---------------------------

$ gcc -O2 -S test.c
$ cat test.s
...
       call    frexp
...

Thanks

Jeremy

-- 
Jeremy Sanders <jss@ast.cam.ac.uk>   http://www-xray.ast.cam.ac.uk/~jss/


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

* Re: frexp function misoptimization
  2008-03-07 12:20 frexp function misoptimization Jeremy Sanders
@ 2008-03-08  2:18 ` Ian Lance Taylor
  2008-03-10  9:28   ` Jeremy Sanders
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2008-03-08  2:18 UTC (permalink / raw)
  To: Jeremy Sanders; +Cc: gcc-help

Jeremy Sanders <jss@ast.cam.ac.uk> writes:

> I notice on x86_64 Linux with gcc-4.1.2, that if I make a call to frexp()
> from math.h, this function is not inlined in the assembly output
> (with -O2). I've tried -ffast-math as well.
>
> As this function could be trivially inlined (it's just a matter of getting
> the correct bits from the stored number), is this a gcc misoptimization or
> is glibc the culprit?

It's just that nobody got around to it.  As it happens, inlining of
frexp is a new optimization in gcc 4.3.

Ian

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

* Re: frexp function misoptimization
  2008-03-08  2:18 ` Ian Lance Taylor
@ 2008-03-10  9:28   ` Jeremy Sanders
  0 siblings, 0 replies; 3+ messages in thread
From: Jeremy Sanders @ 2008-03-10  9:28 UTC (permalink / raw)
  To: gcc-help

Ian Lance Taylor wrote:

> It's just that nobody got around to it.  As it happens, inlining of
> frexp is a new optimization in gcc 4.3.

Great! I apologise about saying "misoptimization" in my previous email - I
meant to say "missing optimization" but I haven't had enough coffee..

Thanks

Jeremy

-- 
Jeremy Sanders <jss@ast.cam.ac.uk>   http://www-xray.ast.cam.ac.uk/~jss/
X-Ray Group, Institute of Astronomy, University of Cambridge, UK.


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

end of thread, other threads:[~2008-03-10  9:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-07 12:20 frexp function misoptimization Jeremy Sanders
2008-03-08  2:18 ` Ian Lance Taylor
2008-03-10  9:28   ` Jeremy Sanders

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