<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><br>
</p>
<div class="moz-cite-prefix">On 03/15/2017 12:01 PM, Stephen Canon
wrote:<br>
</div>
<blockquote
cite="mid:C4B81B47-8F17-4A22-976A-88F4F368903D@apple.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode:
space; line-break: after-white-space;" class="">On Mar 15, 2017,
at 12:52 PM, Hal Finkel <<a moz-do-not-send="true"
href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>>
wrote:<br class="">
<div>
<blockquote type="cite" class="">
<div class="">
<div bgcolor="#FFFFFF" text="#000000" class="">
<p class="">On 03/15/2017 11:39 AM, Stephen Canon wrote:</p>
<blockquote
cite="mid:BC20889E-9FA0-4DB7-836D-33E214002A1B@apple.com"
type="cite" class="">
<div class="">We should default to pragma STDC
FP_CONTRACT ON, not ‘fast’.</div>
<div class=""><br class="">
</div>
<div class="">‘on’ is the most aggressive mode that
conforms to C11. ‘fast’ should be opt-in (like
‘fast-math’ is).</div>
</blockquote>
<br class="">
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).</div>
</div>
</blockquote>
<br class="">
</div>
<div>I’m fine with defaulting to fast in C++ (it’s allowed by
the C++ arithmetic model IIRC).</div>
<div><br class="">
</div>
<div>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.</div>
</div>
</blockquote>
<br>
Oh, good point. We can and should fix this now. All relevant IR
instructions now support fast-math flags (arithmetic, function
calls, etc.). We should have a flag to allow contractions and use
it. This will allow the pragmas to work correctly.<br>
<br>
<blockquote
cite="mid:C4B81B47-8F17-4A22-976A-88F4F368903D@apple.com"
type="cite">
<div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode:
space; line-break: after-white-space;" class="">
<div><br class="">
</div>
<div>“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.</div>
</div>
</blockquote>
<br>
In general, I agree. I think, however, that in this case the other
compilers are right. The statement-limited model is something that,
in my experience, users find surprising and unhelpful. Nevertheless,
I'm fine with having different defaults here for C and C++ (although
somewhat sad) is we want to draw the line at having a confirming
implementation by default. <br>
<br>
-Hal<br>
<br>
<blockquote
cite="mid:C4B81B47-8F17-4A22-976A-88F4F368903D@apple.com"
type="cite">
<div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode:
space; line-break: after-white-space;" class="">
<div><br class="">
</div>
<div>– Steve</div>
</div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>