[llvm-dev] [RFC] FP Contract = fast?
Stephen Canon via llvm-dev
llvm-dev at lists.llvm.org
Wed Mar 15 10:01:06 PDT 2017
On Mar 15, 2017, at 12:52 PM, Hal Finkel <hfinkel at anl.gov> wrote:
> On 03/15/2017 11:39 AM, Stephen Canon wrote:
>
>> We should default to pragma STDC FP_CONTRACT ON, not ‘fast’.
>>
>> ‘on’ is the most aggressive mode that conforms to C11. ‘fast’ should be opt-in (like ‘fast-math’ is).
>
> Why? Other compilers default to 'fast', and 'on' does not play well with C++ code (where inlining is really important, and so the statement boundaries that restrict contraction encourage bad coding style).
I’m fine with defaulting to fast in C++ (it’s allowed by the C++ arithmetic model IIRC).
Personally, I think the bar for not defaulting to the standards-conforming mode should be high. In particular, ‘fast’ doesn’t respect the pragma control, so it is unsafe—if someone copy-pastes code that uses the documented C semantics into a file compiled with ‘fast' set, they will get incorrect behavior, even if they use the pragmas.
“Other compilers are doing it” is not convincing, at all, especially where hard-to-analyze floating-point rounding behavior is concerned. GCC defaulted to preserving extra precision on x87 for decades, and that wasn’t a good idea either. We can do better.
– Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170315/de0fa0ed/attachment.html>
More information about the llvm-dev
mailing list