<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Oops.  Looks like I accidently dropped the mailing list when replying to this.<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></a></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><a name="_____replyseparator"></a><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Kaylor, Andrew
<br>
<b>Sent:</b> Thursday, August 18, 2016 10:02 AM<br>
<b>To:</b> 'Reid Kleckner' <rnk@google.com>; Will <will@millcomputing.com>; Tim Amini Golling <mehdi.amini@apple.com>; Chandler Carruth (chandlerc@gmail.com) <chandlerc@gmail.com><br>
<b>Subject:</b> RE: [llvm-dev] fenv.h vs the optimizer<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">We are definitely interested in correctly handling the FP side effects. 
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I’ve been reading up on the past community discussions of this in hopes of bringing this back into focus.  The last discussion I found on the topic was this thread
 started by Medhi in February:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><a href="http://lists.llvm.org/pipermail/llvm-dev/2016-February/094869.html">http://lists.llvm.org/pipermail/llvm-dev/2016-February/094869.html</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Chandler made a proposal in that thread that seemed to be widely agreed upon, but then as far as I can tell nothing was done to implement it.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">-Andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> llvm-dev [<a href="mailto:llvm-dev-bounces@lists.llvm.org">mailto:llvm-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Reid Kleckner via llvm-dev<br>
<b>Sent:</b> Thursday, August 18, 2016 8:42 AM<br>
<b>To:</b> Will <<a href="mailto:will@millcomputing.com">will@millcomputing.com</a>>; Tim Amini Golling <<a href="mailto:mehdi.amini@apple.com">mehdi.amini@apple.com</a>><br>
<b>Cc:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: [llvm-dev] fenv.h vs the optimizer<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">LLVM has never really supported fenv.h:<o:p></o:p></p>
<div>
<p class="MsoNormal"><a href="https://llvm.org/bugs/show_bug.cgi?id=8100">https://llvm.org/bugs/show_bug.cgi?id=8100</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Even if we added support for the rounding modes, we don't support non-call exceptions either:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="https://llvm.org/bugs/show_bug.cgi?id=1269">https://llvm.org/bugs/show_bug.cgi?id=1269</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I think there is interest in addressing the rounding mode stuff, but less interest in modelling FP side effects. Medhi had some ideas around this.<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Thu, Aug 18, 2016 at 1:12 AM, Will via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal">Howdy all,<br>
<br>
I've been playing around with programs that use the C11 fenv.h.<br>
<br>
It seems that, currently, the LLVM compiler does not regard to the exception-flag side-effects of floating point operations?<br>
<br>
When run on my macbook, the example code on <a href="http://en.cppreference.com/w/c/numeric/fenv/FE_exceptions" target="_blank">
http://en.cppreference.com/w/c/numeric/fenv/FE_exceptions</a> does not print all the expected exceptions.<br>
<br>
Other examples:<br>
<br>
void foo() {<br>
    fesetround(FE_DOWNWARD);<br>
    printf("foo downward: %f\n", rint(0.5));<br>
    fesetround(FE_UPWARD);<br>
    printf("foo upward: %f\n", rint(0.5));<br>
}<br>
<br>
If compiled with optimization, only one call to rint() is made and the result is reused.<br>
<br>
void bar(double a, double b) {<br>
    feclearexcept(FE_INEXACT);<br>
    a / b;<br>
    printf("bar %f / %f is %sexact\n", a, b, fetestexcept(FE_INEXACT)? "in": "");<br>
}<br>
<br>
The compiler omits the divide as the result is unused.  And so on.<br>
<br>
Presumably this has never worked?  And perhaps LLVM is no worse than other compilers in this regard?<br>
<br>
Is there any appetite to fix it?  What kind of changes would need to be made?<br>
<br>
Thx,<br>
<br>
Will<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>