This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: why not consfold sin(const)


 > From: Toon Moene 
 > 
 >  > 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.

If one uses -fno-math-errno, then sqrt is marked "pure".  If you use
-funsafe-math-optimizations then it is marked "const".  (See comments
in builtins.def for ATTR_MATHFN_FPROUNDING and
ATTR_MATHFN_FPROUNDING_ERRNO.)

The g77 frontend sets -fno-math-errno automatically, so I guess it's a
"sensible" language.  However I cannot find where (if) the new fortran
frontend does it.  So it remains to be seen whether that one is
sensible or not. :-)

You may want to check into that.

		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]