<div dir="ltr">LLVM has never really supported fenv.h:<div><a href="https://llvm.org/bugs/show_bug.cgi?id=8100">https://llvm.org/bugs/show_bug.cgi?id=8100</a><br></div><div><br></div><div>Even if we added support for the rounding modes, we don't support non-call exceptions either:</div><div><a href="https://llvm.org/bugs/show_bug.cgi?id=1269">https://llvm.org/bugs/show_bug.cgi?id=1269</a></div><div><br></div><div>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.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 18, 2016 at 1:12 AM, Will via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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" rel="noreferrer" target="_blank">http://en.cppreference.com/w/c<wbr>/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>
______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>