[llvm] [ConstantFolding] Add support for llvm.atan in constant folding. (PR #143416)

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 10 12:36:09 PDT 2025


andykaylor wrote:

> > I think the constant folding just calls the native libm function linked with the compiler.
> 
> Which we really shouldn't be doing, I know @andykaylor has filed an issue on that in the past. The sooner we can get llvm-libc hand-in-hand with APFloat integration, the better.

The issue I had (and I seem to be in the minority in caring about this) is that when we constant fold a transcendental function by calling the libm function, we run the risk of getting a different answer than we would have gotten if the call had been evaluated at runtime if the user binary is linked with a different math library than the compiler. That's a problem of bitwise reproducibility of results.

If the math library linked with the compiler is simply returning an incorrect result (as seems to be the case here) that's a much bigger problem, but it's a problem for the library.

https://github.com/llvm/llvm-project/pull/143416


More information about the llvm-commits mailing list