Optimizing a+b-a-b etc.

Samuel A. Figueroa uunet!SPUNKY.CS.NYU.EDU!figueroa
Sun May 10 19:21:20 PDT 1992


In a previous message Bob Corbett writes:

>> From validgh!uunet!idiap.ch!tmbaSun.COM Sun May 10 13:33:36 1992
>> Date: Sun, 10 May 92 21:37:02 +0200
>> Subject: Re:  Optimizing a+b-a-b etc.
>>  
>> But, please don't spoil C for the "rest of us", who don't want to have
>> to hand-optimize every floating point expression just because some
>> esoteric uses of floating point have ursurped the standard 
>> notation for floating point.
>> 
>> 					Thomas.
>
>Your plea comes years too late.  The ANSI and ISO C Standards
>place tight restrictions on regrouping of expressions.  A
>compiler that does the optimization you describe cannot be part
>of a conforming implementation....  Thus, a conforming implementation
>cannot regroup a floating-point expression in a way that changes
>data written to a file.

But I believe ISO (and ANSI) C has the flaw that there is no model for
floating-point arithmetic.  So while it does appear to place restrictions
on what optimizations a compiler may apply, it says nothing of what the
accuracy of the various arithmetic operations must be.  Therefore, I see
no way that a compiler which performs various "optimizations" and gets
different answers because of this can be called non-conforming - the
compiler writer can simply say that the model of floating-point arithmetic
his or her compiler implements is not as clean as that of the hardware,
for example, and so the results obtained are perfectly reasonable.
------------
Sam Figueroa (figueroaacs.nyu.edu)
This is not a .signature virus.
Do NOT copy me into your .signature file!



More information about the Numeric-interest mailing list