From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,7cd9a3746a6022b2 X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1994-01-14 12:12:44 PST Path: gmd.de!xlink.net!howland.reston.ans.net!vixen.cso.uiuc.edu!sdd.hp.com!decwrl!pa.dec.com!jac.zko.dec.com!gemmax!hobbs From: hobbs@gemmax.enet.dec.com (Steve Hobbs) Newsgroups: comp.sys.dec Subject: Re: DEC C / VAX C problems Date: 14 Jan 1994 18:21:07 GMT Organization: Digital Equipment Corporation Sender: hobbs@gemmax (Steve Hobbs) Distribution: world Message-ID: <2h6nqj$ihq@jac.zko.dec.com> References: <1994Jan14.104449@rzhp9a.gsi.de> Reply-To: hobbs@steven.enet.dec.com (Steven Hobbs) NNTP-Posting-Host: gemmax.zko.dec.com Keywords: DEC C, VAX C, SYSTEM$SPACE, fwrite In article <1994Jan14.104449@rzhp9a.gsi.de>, kaspar@rzhp9a.gsi.de (Matthias Kaspar) asks about the performance of the following program: >#include stdio >#include math > >main() >{ >double x,y=1; >int i; >for (i=0;i<200000000;i++) x=sin(y); >} > It runs very fast calling sin (as written) or calling cos but runs much slower if sin is replaced by tan, sinh, cosh, tanh, or exp. The reason is a compiler optimization which is able to delete all calls to sin or cos because x is a dead variable and sin/cos have no side effects. However, when tan, sinh, cosh, tanh, or exp are called, this optimization cannot be done because these math functions could have the side effect of setting the errno variable. Therefore, in these cases most of the execution time is spent in the math library which is a shareable image placed in system space so that it can be easily shared between different user images.