Article View: comp.sys.sun
Article #12026Re: Fortran 300 times faster than C for computing cosine
From: Chuck Musciano
Date: Tue, 18 Apr 1989 18:17
Date: Tue, 18 Apr 1989 18:17
41 lines
1813 bytes
1813 bytes
Our moderator muses: "Interestingly enough, it [computing a function
involving four calls to cos()] still appears to be quicker [in FORTRAN]
than cosc.c [the C version]".
The answer is that in FORTRAN, cos() is an intrinsic function, and the
compiler uses the direct floating point opcode. In C, cos() is an
external function, and the compiler generates a call to an external named
"cos".
Compare the code generated for "sin(x) + cos(x)" in FORTRAN and C. In
FORTRAN (a5@(-0x7ffc) is x):
fcoss a5@(-0x7ffc),fp0
fsins a5@(-0x7ffc),fp1
faddx fp1,fp0
In C (a6@(-12) and a6@(-16) are x):
movl a6@(-12),sp@-
movl a6@(-16),sp@-
jbsr _sin
addqw #8,sp
movl d0,a6@(-24)
movl d1,a6@(-20)
movl a6@(-12),sp@-
movl a6@(-16),sp@-
jbsr _cos
addqw #8,sp
movl d1,sp@-
movl d0,sp@-
fmoved sp@+,fp0
faddd a6@(-24),fp0
Does anyone know of an optimizer which will convert calls to the standard
math routines to their 68881 instruction counterparts?
Chuck Musciano
Advanced Technology Department
Harris Corporation
(407) 727-6131
ARPA: chuck@trantor.harris-atd.com
Technical Details
Message-ID:
<8903221250.AA03853@trantor.harris-atd.com>Path:
arc1-ca.pugleaf.net!utzoo!dptcdc!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-requestShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!dptcdc!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request From: chuck@trantor.harris-atd.com (Chuck Musciano) Newsgroups: comp.sys.sun Subject: Re: Fortran 300 times faster than C for computing cosine Keywords: Software Message-ID: <8903221250.AA03853@trantor.harris-atd.com> Date: 18 Apr 89 18:17:57 GMT Sender: usenet@rice.edu Organization: Sun-Spots Lines: 41 Approved: Sun-Spots@rice.edu Original-Date: Wed, 22 Mar 89 07:50:52 EST X-Sun-Spots-Digest: Volume 7, Issue 230, message 1 of 16