Bug 14034 is the problem that acos (-1) returns -pi instead of pi in
round-downwards mode, for x86 for all floating-point formats and for
x86_64 for long double (x86_64 #includes the x86 implementation of
acosl). The ISO C requirement is that the result is always in the
range [0, pi].
The problem is that the fsqrt instruction follows the IEEE 754
requirement that sqrt(-0) is -0, and a previous subtraction resulted
in -0 (x-x is -0 in round-downwards mode), so the fpatan instruction
gets a -0 value where it needs a value without the sign bit set to
produce results in the correct quadrant. I propose this patch fixing
this in the obvious way by taking the absolute values of the square
roots. I've added tests for acos in all rounding modes - and for asin
although the similar square roots there do not cause any problems.
Tested x86 and x86_64 and ulps updated accordingly.
2012-04-29 Joseph Myers<joseph@codesourcery.com>
[BZ #14034]
* sysdeps/i386/fpu/e_acos.S (__ieee754_acos): Take absolute value
of square root.
* sysdeps/i386/fpu/e_acosf.S (__ieee754_acosf): Likewise.
* sysdeps/i386/fpu/e_acosl.c (__ieee754_acosl): Likewise.
* math/libm-test.inc (acos_test_tonearest): New function.
(acos_test_towardzero): Likewise.
(acos_test_downward): Likewise.
(acos_test_upward): Likewise.
(asin_test_tonearest): Likewise.
(asin_test_towardzero): Likewise.
(asin_test_downward): Likewise.
(asin_test_upward): Likewise.
(main): Call the new functions.
* sysdeps/i386/fpu/libm-test-ulps: Update.
* sysdeps/x86_64/fpu/libm-test-ulps: Update.