🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #12750

Re: Fortran 300 times faster than C for computing cosine

#12750
From: Ian Phillipps
Date: Thu, 11 May 1989 03:02
44 lines
1757 bytes
chuck@trantor.harris-atd.com (Chuck Musciano) writes:

>Compare the code generated for "sin(x) + cos(x)" in FORTRAN and C.  In
>FORTRAN (a5@(-0x7ffc) is x):

[ 3 x 68881 instructions ]

>In C (a6@(-12) and a6@(-16) are x):

[ 13 x 68020 + 1 x 68881 instructions]

>Does anyone know of an optimizer which will convert calls to the standard
>math routines to their 68881 instruction counterparts?

Sun provide one! (/usr/lib/inline)

Using
	cc -S -O -f68881 trig.c /usr/lib/f68881.il

We get:

	movl    a6@(12),sp@-	; x
	movl    a6@(8),sp@-
	fcosd   sp@,fp0
	fmoved  fp0,sp@
	movl    sp@+,a6@(-8)
	movl    sp@+,a6@(-4)
	movl    a6@(12),sp@-
	movl    a6@(8),sp@-
	fsind   sp@,fp0
	fmoved  fp0,sp@
	movl    sp@+,d0
	movl    sp@,d1
	movl    d0,sp@-
	fmoved  sp@+,fp0
	faddd   a6@(-8),fp0
	fmoved  fp0,a6@(16)	; assign result

Not very optimised, but at least it does fcosd!
[Note - C gives you DCOS by default]
-- 
UUCP:  igp@camcon.co.uk   | Cambridge Consultants Ltd  |  Ian Phillipps
or:    igp@camcon.uucp    | Science Park, Milton Road  |-----------------
Phone: +44 223 420024     | Cambridge CB4 4DW, England |
Technical Details
Message-ID: <2850@titan.camcon.co.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!husc6!rice!sun-spots-request
References: <8903221250.AA03853@trantor.harris-atd.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!husc6!rice!sun-spots-request
From: igp@cambridge-consultants.co.uk (Ian Phillipps)
Newsgroups: comp.sys.sun
Subject: Re: Fortran 300 times faster than C for computing cosine
Keywords: Software
Message-ID: <2850@titan.camcon.co.uk>
Date: 11 May 89 03:02:32 GMT
References: <8903221250.AA03853@trantor.harris-atd.com>
Sender: usenet@rice.edu
Organization: Cambridge Consultants Ltd., Cambridge, UK
Lines: 44
Approved: Sun-Spots@rice.edu
Original-Date: 5 May 89 13:08:40 GMT
X-Sun-Spots-Digest: Volume 7, Issue 281, message 4 of 19