public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Roger Sayle <roger@eyesopen.com>
To: Scott Robert Ladd <coyote@coyotegulch.com>
Cc: gcc@gcc.gnu.org
Subject: Re: GCC viciously beaten by ICC in trig test!
Date: Mon, 15 Mar 2004 01:55:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.44.0403141713460.12909-100000@www.eyesopen.com> (raw)
In-Reply-To: <4054ED19.8020009@coyotegulch.com>


On Sun, 14 Mar 2004, Scott Robert Ladd wrote:
> Consider the following program, compiled and run on a Pentium 4
> (Northwood) system:
>
>      #include <math.h>

For a number of benchmarks, just this first line of source code above
is enough to loose the race for GCC against Intel when compiling on Linux.

Consider the following:

	#include <math.h>

	double doit(double a)
	{
	  return sin(a) * sin(a);
	}


Compiling with gcc -O2 -ffast-math on Linux generates x86 code that's
significantly slower than Intel's compiler output.  However, commenting
out the "#include <math.h>" corrects the situation and GCC can then
generate *exactly* the same sequence as icc.


The issue is that glibc's headers provide inline implementations for sin
and cos, and thereby override all of GCC's internal builtin processing.
Once this is done, there's nothing tree-ssa, the middle-end or the i386
can do to improve the code.  If GCC is to have a hope of using "sincos"
or SSE2 specific instruction sequences, the "best intentions" of glibc's
headers (will) have to be neutralized first.  Perhaps fixincludes :>


For the interested with "#include <math.h>" GCC 3.3.3 generates

foo:    fldl    4(%esp)
        fld     %st(0)
#APP
        fsin
#NO_APP
        fxch    %st(1)
#APP
        fsin
#NO_APP
        fmulp   %st, %st(1)
        ret

without it, the same "-O2 -ffast-math -fomit-frame-pointer" options'
output is identical to the output from Intel v7.0 (and presumably later).

foo:    fldl    4(%esp)
        fsin
        fmul    %st(0), %st
        ret


Just another data point.  Avoiding <math.h> may improve your performance
and influence the results of your "command line option" experiments.

Roger
--

  parent reply	other threads:[~2004-03-15  1:55 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-14 23:40 Scott Robert Ladd
2004-03-14 23:49 ` Gabriel Dos Reis
2004-03-15  1:47   ` Scott Robert Ladd
2004-03-15  0:11 ` Paolo Carlini
2004-03-15  1:47   ` Scott Robert Ladd
2004-03-15  2:07     ` Daniel Berlin
2004-03-15  2:30       ` Scott Robert Ladd
2004-03-15  2:31         ` Daniel Berlin
2004-03-15  2:38           ` Scott Robert Ladd
2004-03-15 10:00             ` Sebastian Pop
2004-03-15  0:12 ` GCC beaten by ICC in stupid " Andrew Pinski
2004-03-15  0:32   ` Paolo Carlini
2004-03-15  1:31   ` Scott Robert Ladd
2004-03-15  2:36   ` Scott Robert Ladd
2004-03-15 11:25   ` Paolo Carlini
2004-03-15 11:31     ` Paolo Carlini
2004-03-15 13:29     ` Zdenek Dvorak
2004-03-15 13:42       ` Paolo Carlini
2004-03-15 13:51         ` Zdenek Dvorak
2004-03-15 13:55           ` Paolo Carlini
2004-03-15 14:00             ` Zdenek Dvorak
2004-03-15 14:05           ` Joseph S. Myers
2004-03-15 14:13             ` Paolo Carlini
2004-03-15 14:18               ` Zdenek Dvorak
2004-03-15 14:29                 ` Segher Boessenkool
2004-03-15 14:28               ` Joseph S. Myers
2004-03-15  1:55 ` Roger Sayle [this message]
2004-03-15  2:22   ` GCC viciously beaten by ICC in " Dan Nicolaescu
2004-03-15 12:05     ` Stelios Xanthakis
2004-03-15 18:22       ` Dan Nicolaescu
2004-03-15  2:41   ` Scott Robert Ladd
2004-03-15  3:05     ` Gabriel Dos Reis
2004-03-15 14:47       ` Segher Boessenkool
2004-03-15 17:44         ` Geert Bosch
2004-03-15 17:46           ` Geert Bosch
2004-03-15  2:41   ` Kaveh R. Ghazi
2004-03-15  6:06     ` Andreas Jaeger
2004-03-15  8:57       ` Gabriel Dos Reis
2004-03-15  3:01   ` Gabriel Dos Reis
2004-03-15  4:06     ` Scott Robert Ladd
2004-03-15  5:15   ` James Morrison
2004-03-15  8:20     ` Jakub Jelinek
2004-03-15 18:13       ` Joe Buck
2004-03-16 13:31         ` Jakub Jelinek
2004-03-15  7:42   ` Ranjit Mathew
2004-03-15 19:00   ` Toon Moene
2004-03-15 19:44     ` Laurent GUERBY
2004-03-15  3:19 Stephan T. Lavavej
2004-03-15  3:29 ` Gabriel Dos Reis
2004-03-15 12:40   ` Scott Robert Ladd
2004-03-15 12:53     ` Gabriel Dos Reis
2004-03-15 13:37       ` Scott Robert Ladd
2004-03-15 15:11     ` Ian Lance Taylor
2004-03-15 16:25       ` Stephan T. Lavavej
2004-03-15 16:40         ` Jakub Jelinek
2004-03-15 16:46         ` Ian Lance Taylor
2004-03-15 16:56           ` Paolo Carlini
2004-03-15 17:10             ` Gabriel Dos Reis
2004-03-15 17:15               ` Paolo Carlini
2004-03-15 17:58                 ` Gabriel Dos Reis
2004-03-15 16:59           ` Gabriel Dos Reis
2004-03-15 17:28             ` Ian Lance Taylor
2004-03-15 17:47               ` Gabriel Dos Reis
2004-03-15 17:52               ` Joe Buck
2004-03-15 17:53               ` Phil Edwards
2004-03-15 17:45     ` Joe Buck
2004-03-15 19:50       ` Scott Robert Ladd
2004-03-16  1:00     ` Zack Weinberg
2004-03-17  0:07       ` Kai Henningsen
2004-03-16 23:12   ` Kai Henningsen
2004-03-17  3:00     ` Ian Lance Taylor
2004-03-15 17:42 ` Joe Buck
2004-03-17  0:31 Stephan T. Lavavej
2004-03-17  3:30 ` Ian Lance Taylor

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=Pine.LNX.4.44.0403141713460.12909-100000@www.eyesopen.com \
    --to=roger@eyesopen.com \
    --cc=coyote@coyotegulch.com \
    --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).