<div dir="ltr"><div>The answer lies inside of <span style="color:rgb(0,0,0);font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">canCombineSinCosLibcall </span>in <span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0);font-family:menlo;font-size:11px">lib/CodeGen/SelectionDAG/LegalizeDAG.cpp</span><font color="#000000" face="menlo"><span style="font-size:11px;font-variant-ligatures:no-common-ligatures">:</span></font></div>







<div><br></div><div>....</div><div><div>  // GNU sin/cos functions set errno while sincos does not. Therefore</div><div>  // combining sin and cos is only safe if unsafe-fpmath is enabled.</div><div>....</div></div><div><br></div><div>unsafe-fpmath is enabled with -ffast-math. </div><div><br></div><div>I.e. folding to sincos is unlikely to be standard compliant. It's also the reason why <cmath> functions can not marked constexpr :-/</div><div><br></div><div>IMHO, errno is an anachronism and should never have been included as a part of <cmath>. I would personally like the base <cmath> functions to be wholly ignorant of errno, and there to be a separate set of <cmath> functions that throw the appropriate exceptions for those rare cases where knowledge of domain errors is important. </div><div><br></div><div>I've yet to come across production code that checks errno in any capacity after calling a math function (language support libraries excepted). I feel that the errno requirement is a rare case that unfortunately affects the optimizability of a large portion of code that could benefit from its absence altogether.</div><div><br></div><div class="gmail_extra"><div><div class="gmail_signature"> - ½<br></div></div>
<br><div class="gmail_quote">On 18 May 2017 at 10:20, René J.V. Bertin via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Thursday May 18 2017 14:55:03 Dennis Luehring wrote:<br>
<br>
>clang DOES use sincos if -ffast-math option is given<br>
>gcc use it even without -ffast-math<br>
<br>
</span>To make matters even more complex: on Mac the situation is the opposite, that is clang always uses a sincos library function provided by Apple.<br>
<span class="gmail-"><br>
>i don't think its the x87 opcode - because then LLVM would inline it - and not using a call<br>
<br>
</span>That depends, LLVM cannot know how the sincos() function from libm is implemented.<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
R.<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div></div>