[MLton-devel] cvs commit: Real32 and Real64 improvements

Stephen Weeks MLton@mlton.org
Fri, 5 Sep 2003 11:51:24 -0700


> I'm curious with regards to the remaining incompatibilities if you were using
> the -ffast-math option on the C compiles.  The info pages for gcc talk  about
> this  being  turned  off  by default on FreeBSD.  I remember us talking about
> turning it on so that the assembler instructions would  be  used  since  they
> were faster and didn't seem to cause any problems that we could see.

I see a discussion from August 2001 about gcc and -ffast-math.  I just
ran some tests again to see what's going on.  It seems that on X86
with cos (and I would assume sin, tan, ...), the C call is used with
no -ffast-math and an instruction is used with -ffast-math.  On the
other hand, the use of the sqrt instruction seems to be independent of
-ffast-math and only depends on the -O level.  Here's a table showing
where gcc generates the instruction.

gcc flags		cos	sqrt
---------------		---	----
-O0			no	no
-O1			no	yes
-O2			no	yes
-O0 -ffast-math		yes	no
-O1 -ffast-math		yes	yes
-O2 -ffast-math		yes	yes

In any case, it really isn't reasonable for us to use -ffast-math,
because it messes up the semantics of basic arithmetic and
comparisons.  For example, with -ffast-math, posInf - posInf = 0, when
the spec says it should be nan.  Also comparisons with nan return
TRUE, when they should return FALSE.  Of course, it's still possible
if you really want it to compile with -cc-opt -ffast-math.



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel