This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: why not consfold sin(const)
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: Robert Dewar <dewar at gnat dot com>
- Cc: Luchezar Belev <l_belev at yahoo dot com>, gcc at gcc dot gnu dot org
- Date: Mon, 20 Sep 2004 20:29:52 +0200
- Subject: Re: why not consfold sin(const)
- Organization: Moene Computational Physics, Maartensdijk, NL
- References: <20040919183425.53419.qmail@web52801.mail.yahoo.com> <414DD2E0.607@gnat.com>
Robert Dewar wrote:
Of course in practice a constant like this will often be pulled
out of loops, CSE'ed etc, so the impact may be smaller than
expected.
In sensible languages for floating point computations, yes. One has to
conclude, though, that floating point arithmetic was added as an
afterthought to C - not surprising, given its initial niche.
All functions in <math.h> can set errno for domain and range errors; in
other words, those functions are not pure, and cannot be moved out of
loops or CSE'd away.
Obviously, with some effort it might be possible to get gcc to the point
where it can prove for a set of useful constants that, e.g., sqrt cannot
possibly have to set errno and that the call therefore might be assumed
pure.
--
Toon Moene - e-mail: toon@moene.indiv.nluug.nl - phone: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
A maintainer of GNU Fortran 95: http://gcc.gnu.org/fortran/