Created attachment 8091 [details]
fma rounding mode test function
The software fma function modifies the rounding mode for SSE floating point instructions (to round-toward-zero), but does not reset it correctly, on 32bit (686) processors. The x87 rounding mode is unaffected.
Attached is a sample program: compile on a 32bit machine with gcc:
$ gcc fmacheck.c -o fmacheck -lm -msse2 -mfpmath=sse
$ clang fmacheck.c -o fmacheck -lm
When run as
$ ./fmacheck 0x1.0000000000001p+0
it should give
if rounding mode is the default (round-to-nearest). If the rounding mode has been incorrectly modified to be round-toward-zero, then you will get
This looks like it would have been a consequence of bug 16064, fixed for 2.20.
*** This bug has been marked as a duplicate of bug 16064 ***
(More specifically: i386 uses sysdeps/ieee754/ldbl-96/s_fma.c, which saves
state with feholdexcept, sets the rounding mode (twice) with fesetround,
and then restores state, with exceptions merged, with feupdateenv. This
was the sort of pattern that was mishandled before bug 16064 was fixed,
because fesetround sets the SSE rounding mode but the fenv_t functions
used not to handle it.)
Great, thanks for letting me know.