[libc-commits] [libc] [libc] Prevent constant propagation for atanf(+-Inf) in gcc. (PR #85733)

via libc-commits libc-commits at lists.llvm.org
Tue Mar 19 08:15:05 PDT 2024


lntue wrote:

> A side question, what should be the best way to mark a value as nondeterministic (non constant)?

So far I found using `volatile` variables in the intermediate works well enough on both clang and gcc, especially on non-critical paths, since it might induce some performance penalty.  For floating point computations, adding `-frounding-math` will prevent a lot of constant foldings of arithmetic operations.  But that flag will be applied to the whole translation unit, and it might be a bit tricky/unpredictable when `constexpr` is also involved.  There might be some other `asm` tricks, but it will most likely have to be platform-specific.

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


More information about the libc-commits mailing list