Fix dbl-64/wordsize-64 remquo (bug 17569).
commitd9afe48d55a412e76b0dcb28335fd4b390fe07ae
authorJoseph Myers <joseph@codesourcery.com>
Fri, 13 Feb 2015 21:54:44 +0000 (13 21:54 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Fri, 13 Feb 2015 21:54:44 +0000 (13 21:54 +0000)
treecebb0e3a23be3a2e930fef5b8ed43d0d83a2d265
parent3846188b21eaae3fc57e399a9aead34847521bbb
Fix dbl-64/wordsize-64 remquo (bug 17569).

The dbl-64/wordsize-64 remquo implementation follows similar logic to
various other implementations, but where that logic computes some
absolute values, it wrongly uses a previously computed bit-pattern for
the absolute value of the first argument, where actually it needs the
absolute value of the first argument mod 8 times the second.  This
patch fixes it to compute the correct absolute value.

The integer quotient result of remquo is only specified mod 8
(including its sign); architecture-specific versions may well vary in
what results they give for higher bits of that result (and indeed bug
17569 gives an example correct result from __builtin_remquo giving 9
for that result, where the particular glibc implementation used in
that bug report would give 1 after this fix).  Thus, this patch adapts
the tests of remquo to test that result only mod 8, to allow for such
variation when tests with higher quotient are included.

Tested for x86_64 and x86.

[BZ #17569]
* sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c (__remquo):
Compute absolute value of x as modified by fmod, not original
value of x.
* math/libm-test.inc (RUN_TEST_ffI_f1): Rename to
RUN_TEST_ffI_f1_mod8.  Check extra return value mod 8.
(RUN_TEST_LOOP_ffI_f1): Rename to RUN_TEST_LOOP_ffI_f1_mod8.  Call
RUN_TEST_ffI_f1_mod8.
(remquo_test_data): Add more tests.
ChangeLog
NEWS
math/libm-test.inc
sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c