[cfe-dev] [llvm-dev] Floating point semantic modes

Szabolcs Nagy via cfe-dev cfe-dev at lists.llvm.org
Wed Jan 29 03:18:55 PST 2020


* Blower, Melanie I <melanie.blower at intel.com> [2020-01-28 19:24:24 +0000]:
> About math-errno:
> There are comments in the clang code that describe the settings for math-errno as toolchain dependent. Here's the initialization:
>   // -fmath-errno is the default on some platforms, e.g. BSD-derived OSes.
>   bool MathErrno = TC.IsMathErrnoDefault();

that's interesting since the bsd libm does not touch errno
(at least on freebsd), so for them this creates significant
overhead (e.g. when sqrt is inlined, the compiler still emits
code to check the input and fall back to the libc sqrt call
just in case it wants to set errno)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37073

>   Here's another comment,
>       // Turning *off* -ffast-math restores the toolchain default.
>       MathErrno = TC.IsMathErrnoDefault();

i guess the default can be tied to the libm behaviour of the
target (but ideally it will be the same everywhere so it's
easier to get portable behaviour)

(i personally would get rid of math errno, it causes problems,
but i think the gcc/glibc position is that c89 only had errno,
no fenv exceptions, so it should be supported for bw compat)


More information about the cfe-dev mailing list