Add setpayloadsig, setpayloadsigf, setpayloadsigl [committed]
Stefan Liebler
stli@linux.vnet.ibm.com
Wed Jan 11 12:40:00 GMT 2017
On 11/25/2016 12:58 AM, Joseph Myers wrote:
> TS 18661-1 defines functions for manipulating the payloads of NaNs.
> This patch implements the setpayloadsig functions for glibc; these are
> like the setpayload functions, but produce a signaling NaN instead of
> a quiet NaN.
>
> The substance of the implementation was included with the setpayload
> implementation, so the new files here just need to wrap the main files
> with different defines to build the new functions.
>
> Because the functions store a signaling NaN via a pointer and the
> libm-test macros choose a suitable initial value for the variable in
> such a case by comparing with the expected value, the relevant macro
> needs to clear exceptions after FE_INVALID may have been raised by
> that comparison.
>
> Tested for x86_64, x86, mips64 and powerpc. Committed.
As information:
On s390x, the setpayloadsig tests which produces a snan value are
failing with:
testing double (inline functions)
Failure: Test: setpayloadsig (0x1p0) extra output 1
Result:
is: sNaN
should be: qNaN
The implementation of setpayloadsig is correct!
There is a zero comparison in math/libm-test.inc:
#define RUN_TEST_Ff_b1(...) ... \
(EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0; \
...
If this comparison is done with the floating-point load-and-test
instruction, the sNaN value in EXTRA_EXPECTED results in a qNaN value.
This value is used in subsequent code and produces the test fail.
Whether the test fails or not depends on used gcc and
optimization-level. E.g. using gcc 4.8.5 -O2 leads to test fails in
math/test-ifloat, math/test-idouble, math/test-ildouble.
If -O3 is used, the tests pass as this code does not use the
load-and-test instruction.
This is a gcc bug.
See "Bug 78857 - S390: Do not use load-and-test floating-point
instruction to compare against 0.0 as SNaN is converted to QNaN."
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78857)
Bye
Stefan
More information about the Libc-alpha
mailing list