On Wed, 16 Feb 2005, Linus Torvalds wrote:
> 
> Yeah, yeah, some FP people will disagree. FP people are a damn 
> disagreeable lot, and I just don't care. 

Side note: from what I've seen, even the disagreeable FP people have long
since given up, and if they don't trust the compiler (and they won't,
since by definition they are disagreeable), they'll make their strict
bit-for-bit requirements by just writing the FP number as a hexadecimal
constant. Again - the compiler FP constant code has nothing to do with it.

What the compiler FP constant arithmetic should care about is the 
"obvious" cases, because it can't get the non-obvious cases right anyway. 

So FP constant folding should try to get the "obvious" answer to things 
like "2*0.5" right, which btw means that it should absolutely avoid tryign 
to think about rounding modes (ie it should always round-to-nearest, and 
screw the fact that maybe the user has asked for a different rounding 
mode).

Try this program:

        #include <math.h>
        #include <fenv.h>
        #include <sched.h>

        double hide(double);

        int main(int argc, char **argv)
        {
                double x = hide(3);
                double y = hide(1/3.0);

                fesetround(FE_TOWARDZERO);
        
                printf("%.20lf\n", x*y);        
                return 0;
        }

        double hide(double x)
        {
                return x;
        }

with and without the "fesetround()" to see what I'm talking about. One
case will return 1 (with a lot of zeroes), while the other will return
0.99999999999999988898 (on the particular architecture where I happened to
test this).

The compiler CANNOT do that FP math simplification "right" (where "right"  
means "same as if it didn't simplify"). End of story.

                Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to