From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bd74f408cd771388,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-09 13:30:29 PST Message-ID: <3F0C7B5D.81F0FDCD@somewhere.nil> Date: Wed, 09 Jul 2003 22:30:21 +0200 From: Gautier Write-only X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Compute a Sin(X) and Cos(X) pair, FSINCOS, inlining Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 80.218.248.105 X-Trace: news.swissonline.ch 1057782628 80.218.248.105 (9 Jul 2003 22:30:28 +0200) X-Complaints-To: abuse@swissonline.ch Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-pas-nf2!elnk-atl-nf1!newsfeed.earthlink.net!in.100proofnews.com!in.100proofnews.com!nntp.infostrada.it!news.mailgate.org!news-zh.switch.ch!switch.ch!news.swissonline.ch!not-for-mail Xref: archiver1.google.com comp.lang.ada:40149 Date: 2003-07-09T22:30:21+02:00 List-Id: 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!