[llvm] [LLVM] Add constant folding for llrint, llrintf, llrintl (PR #154799)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 22 09:42:06 PDT 2025


nikic wrote:

> Why do you need to directly constant fold the libcalls? We have intrinsics for these, which we arguably should just always replace libcalls with

This is a great question. I assumed this is because of the usual issue where the libcall may set errno and intrinsics don't. But these particular functions are specified to not set errno.

The intrinsic *is* emitted if you use `-fno-math-errno` though. So I think these builtins may have just been misclassified in clang codegen and should be switched to emit the intrinsic unconditionally (not inside the GenerateIntrinsics conditional).

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


More information about the llvm-commits mailing list