[llvm-dev] RFC: Constant folding math functions for long double

Neil Henning via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 4 07:18:08 PDT 2016


Please not (1).

Cheers,
-Neil.

On 04/04/16 14:59, James Molloy via llvm-dev wrote:
> Hi,
>
> Clang is currently unable to constant fold calls to math.h functions 
> such as logl(), expl() etc.
>
> 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.
>
> I can see three methods for allowing constant folding for types that 
> are larger than double, some more expensive than others:
>
> 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.
> 2. Write the trancendental functions ourselves in APFloat (yuck!)
> 3. If the long double format on the compiler host is the same as the 
> target, use the host library.
>
> (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).
>
> What do people think about (1)? Or is this completely out of the question?
>
> Cheers,
>
> James
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160404/d91fc527/attachment.html>


More information about the llvm-dev mailing list