<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">That sounds like a library issue that qualifies as “somewhat strange”.  Why does this require a log at all?</div><div class=""><br class=""></div><div class="">– Steve</div><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 4, 2016, at 10:46 AM, James Molloy via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Joerg,<div class=""><br class=""></div><div class="">> <span style="line-height:1.5" class="">IMO if constant folding of transcendental functions makes a significant</span></div>difference for your program, you likely are doing something strange<br class="">already.<div class=""><br class=""></div><div class="">Alas it's not as simple as that. Currently, if you declare:</div><div class=""><br class=""></div><div class="">std::uniform_real_distribution<float> x;</div><div class=""><br class=""></div><div class="">LLVM emits two calls to logl() with constant arguments, a fdiv and a fptoui.</div><div class=""><br class=""></div><div class="">Libc++'s implementation is consumed and folded much more nicely by LLVM, but at the moment anyone comparing LLVM and GCC will think that GCC is around 40% better for some workloads.</div><div class=""><br class=""></div><div class="">James</div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, 4 Apr 2016 at 17:49 Reid Kleckner <<a href="mailto:rnk@google.com" class="">rnk@google.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">My feeling is that we shouldn't be relying on host long double routines. We're already skating on thin ice by relying on host double and float routines. This is a great way to make the compilation result vary depending on the host, which is something we try to avoid.<div class=""><br class=""></div><div class="">An optional MPFR dependency would also be pretty painful. I expect it will frequently be missing and will not be exercised by most buildbots.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 4, 2016 at 6:59 AM, James Molloy via llvm-dev <span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span> wrote:<br class=""></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><span style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class="">Hi,</span><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class=""><br class=""></div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class="">Clang is currently unable to constant fold calls to math.h functions such as logl(), expl() etc.</div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class=""><br class=""></div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class="">The problem is that APFloat doesn't have these functions, so Clang is forced to rely on the host math library. Because long double isn't portable, we only ever query the host math library for double or float results.</div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class=""><br class=""></div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class="">I can see three methods for allowing constant folding for types that are larger than double, some more expensive than others:</div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class=""><br class=""></div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class="">  1. Introduce a dependency on libMPFR, as GCC does. The dependency could be hard or soft, with a fallback to the current behaviour if it doesn't exist.</div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class="">  2. Write the trancendental functions ourselves in APFloat (yuck!)</div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class="">  3. If the long double format on the compiler host is the same as the target, use the host library.</div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class=""><br class=""></div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class="">(2) is the hardest. (3) is the easiest, but only works in a subset of cases and I really don't like the idea of better output when compiling on one platform compared to another (with equivalent targets).</div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class=""><br class=""></div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class="">What do people think about (1)? Or is this completely out of the question?</div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class=""><br class=""></div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class="">Cheers,</div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class=""><br class=""></div><div style="color:rgb(33,33,33);font-size:13px;line-height:19.5px" class="">James</div></div>
<br class=""></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="">
<br class=""></blockquote></div></div></blockquote></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></body></html>