Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: hobbs@gemmax.enet.dec.com (Steve Hobbs)
Subject: Re: DEC C / VAX C problems
Date: 14 Jan 1994 18:21:07 GMT	[thread overview]
Message-ID: <2h6nqj$ihq@jac.zko.dec.com> (raw)
In-Reply-To: 1994Jan14.104449@rzhp9a.gsi.de

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.


  reply	other threads:[~1994-01-14 18:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-01-14  9:44 DEC C / VAX C problems Matthias Kaspar
1994-01-14 18:21 ` Steve Hobbs [this message]
1994-01-18 20:11 ` Ken Cowan
read-only archive

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