On Wed, 16 Feb 2005, Chris Lattner wrote:
The compiler CANNOT do that FP math simplification "right" (where "right" means "same as if it didn't simplify"). End of story.
Note that your example isn't a conformant C99 program unless you use the "#pragma STDC FENV_ACCESS" pragma, to tell the compiler that you're messing with rounding modes.
http://www.iyonix.com/tools/c99pragmas.shtml
Given conformant programs and a correct compiler, the things you're claiming are impossible are quite possible. That said, those two assumptions are hard to satisfy these days. :)
I stand by my claim.
The compiler can _avoid_ doing any FP simplification at all. But the compiler ABSOLUTELY CANNOT do FP math simplification and still give the same result as run-time would. It's one of either: "don't simplify constants" or "simplify constants and perhaps get it wrong". See my argument? In neither case is it a case of "add complex software calculation routines". It's an "either do, or do not".
No, you're missing the point. The point is that C allows the compiler to do exactly the simplifications we all want, UNLESS, FENV_ACCESS is explicitly used to tell it not to. IFF the pragma is set, the compiler's "hands" are tied: otherwise (common case) it can do whatever it wants.
This is similar to how volatile affects redundancy elimination.
What you can do is have a notion of "exact", of course. "2.0*0.5" can always be simplified, simply because they are exactly representable regardless of rounding modes. You don't actually need to have any SW Fp for that, though, since the HW FP itself will obviously be perfectly fine for this case.
Sure, and that's an example of the kind of optimization you could do even if the FENV_ACCESS pragma is set.
I still maintain that the number of people that really care is starting to be infinitesimal.
Note that I'm not claiming that *you* or *sparse* should care, I'm just saying that C99 makes all of these things quite possible for conformant compilers.
-Chris
-- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/ - 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
