This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC viciously beaten by ICC in trig test!

On Mon, 2004-03-15 at 20:05, Toon Moene wrote:
> Roger Sayle wrote:
> > 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.
> Indeed - and that's the basic reason why you should write this kind of 
> software in Fortran: No pesky header files destroying your carefully 
> optimized code ....
> [ OK, I couldn't resist :-) :-) ]

Arghhh tempting... or Ada? With GCC 3.3.2 from Fedora Core 1, the do_it
call is removed from the loop at -O1 (the curious can check pragma Pure
in the Ada Reference Manual).



with Ada.Numerics.Long_Elementary_Functions;
with Ada.Text_IO;

procedure P1 is
   use Ada.Numerics.Long_Elementary_Functions;
   use Ada.Text_IO;

   subtype Num is Long_Float;

   function Do_It (A : in Num) return Num is
      C : constant Num := Cos (A);
      S : constant Num := Sin (A);
      return S * S + C * C;
   end Do_It;

   A : Num := 1.0;
   R : Num := 0.0;

   for I in 1 .. 100_000_000 loop
      R := R + Do_It (A);
   end loop;

   Put_Line (Num'Image (R));
end P1;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]