3 ms·
> in particular, floating point is done even worse than C Do you mind expanding on this or pointing me to places where I can read more?
by aw1621107 7y ago
> in particular, floating point is done even worse than C
Do you mind expanding on this or pointing me to places where I can read more?
- jcranmer 7y agoThere is a hidden floating-point environment that affects, and is affected by, every single floating-point instruction. Predominantly, this is rounding mode control, sticky bits, and exception control (does overflow cause a SIGFPE?), although most processors have some form of flushing denormals or treating them as 0s, which isn't in IEEE 754. LLVM's floating point instructions assume that there is no floating point environment [1]. And there's no real facility to indicate that floating point instructions might be affected. To remedy this, they've been working on adding constrained floating point intrinsics. [1] More specifically, that the environment is set up to the default rounding mode (round-nearest), all exceptions are masked, and no one will ever care about sticky bits.
- brandmeyer 7y agoIs GIMPLE any worse or better in this regards?
- jcranmer 7y agoI don't have much experience with GCC innards, but after doing a quick test [1], it seems GCC is as bad as clang in terms of not supporting STDC FENV_ACCESS, so I suspect the answer is that it's pretty much the same. It looks like the only major compiler that actually supports IEEE 754 correctly is icc. MSVC, gcc, and clang all optimize floating-point operations without considering if the dynamic environment is the same. [1] https://godbolt.org/z/x2ERVM https://godbolt.org/z/x2ERVM