[libcxx-commits] [clang] [libcxx] [Clang] Allow __builtin_fma/fmaf/fmal to be used in a constant expression (PR #158048)

Hubert Tong via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 19 13:11:58 PDT 2025


hubert-reinterpretcast wrote:

> * If `FENV_ACCESS` is off and `FENV_ROUND` is present, then we are in the fully default FP environment except that the rounding mode isn't necessarily in the default rounding mode. We can do the translation at compile-time, even if `FENV_ROUND` is `FE_DYNAMIC` (since the translator is explicitly allowed to assume that it's in the default round per the C specification).

Okay, but for the question of whether the "constant rounding mode" or "dynamic round mode" is used for this folding outside of a manifestly constant-evaluated context, I think it should actually be the "dynamic rounding mode" (i.e., default rounding with `FENV_ROUND` effectively ignored) if the call is not `__builtin_`-prefixed. This goes back to the responsibility of some header to modify calls that are subject to `FENV_ROUND`-controlled behaviour via macro replacement (e.g., to call a different built-in).

I think the `__builtin_`-prefixed cases should behave the same unless there is a compelling reason to do otherwise.

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


More information about the libcxx-commits mailing list