comp.lang.ada
 help / color / mirror / Atom feed
From: Gautier Write-only <gautier@somewhere.nil>
Subject: Compute a Sin(X) and Cos(X) pair, FSINCOS, inlining
Date: Wed, 09 Jul 2003 22:30:21 +0200
Date: 2003-07-09T22:30:21+02:00	[thread overview]
Message-ID: <3F0C7B5D.81F0FDCD@somewhere.nil> (raw)

Hello!

In some FPUs (like the Intel x387), Sin and Cos are computed simultaneously.
There is an instruction (Intel x387: FSINCOS) to get both together for +/- the
time cost of one of each.

Is there a way to make a compiler inline sufficienly the Run-Time library
and detect cases where Sin(X) and Cos(X) are in one area and X is the
same expression, in order to produce a FSINCOS instruction ?

(Example: in GNAT's Ada.Numerics.Generic_Complex_Elementary_Functions :
   function Exp (X : Imaginary) return Complex is
      ImX : Real'Base := Im (X);
   begin
      return Compose_From_Cartesian (Cos (ImX), Sin (ImX));
   end Exp;
)

I have tried with GNAT 3.15p for Win32 and the options "-gnatpN -O3", but
in vain. At best I obtain inlined FCOS and FSIN instructions, separately.
ObjectAda SE 7.2.2 (Win32, release mode) also computes Sin and Cos separately.
Of course there are also "safety belts" around both FPU calls that bring
more distance between them in the assembler code, making this optimization
perhaps less likely to happen.

A solution would be to add a Sin_Cos procedure to the Ada 0Y standard.

TIA for any hint or debate.
________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!



             reply	other threads:[~2003-07-09 20:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-09 20:30 Gautier Write-only [this message]
2003-07-09 20:40 ` Compute a Sin(X) and Cos(X) pair, FSINCOS, inlining Florian Weimer
2003-07-10  1:51 ` Jeffrey Carter
2003-07-12  6:26 ` Gautier Write-only
2003-07-13 23:32   ` Jerry van Dijk
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox