]> gcc.gnu.org Git - gcc.git/commit
Fix libdecnumber handling of non-canonical BID significands (PR middle-end/91226).
authorJoseph Myers <joseph@codesourcery.com>
Mon, 9 Dec 2019 13:59:24 +0000 (13:59 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Mon, 9 Dec 2019 13:59:24 +0000 (13:59 +0000)
commit0fad54f0a88160e81c3150b63c91fd9809665474
tree950d485dda0093ffc3c0d8df0ffdd7264b1ef61d
parent8d106dd51fac1a524ede3019769c214668021350
Fix libdecnumber handling of non-canonical BID significands (PR middle-end/91226).

As reported in bug 91226, the libdecnumber code used on the host to
interpret DFP values in the BID encoding fails, for _Decimal64 and
_Decimal128, to check for the case where a significand is too large
and so specified in IEEE 754 to be a non-canonical encoding of the
zero significand.  This patch adds the required handling of that case,
together with tests both using -O2 (testing this host code) and -O0
(testing libgcc code, which already worked before the patch); the
tests also cover _Decimal32, which already had the required check.

In the _Decimal128 case, where the code previously completely ignored
the case where the first four bits of the combination field are 1100,
1101 or 1110, the logic for determining the correct quantum exponent
in that case is also newly added by this patch, so tests are added for
that as well (again, libgcc already handled it correctly when the
conversion was done at runtime rather than at compile time).

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

PR middle-end/91226
libdecnumber:
* bid/bid2dpd_dpd2bid.c (_bid_to_dpd64): Handle non-canonical
significands.
(_bid_to_dpd128): Likewise.  Check for case where combination
field starts 1100, 1101 or 1110.

gcc/testsuite:
* gcc.dg/dfp/bid-non-canonical-d128-1.c,
gcc.dg/dfp/bid-non-canonical-d128-2.c,
gcc.dg/dfp/bid-non-canonical-d128-3.c,
gcc.dg/dfp/bid-non-canonical-d128-4.c,
gcc.dg/dfp/bid-non-canonical-d32-1.c,
gcc.dg/dfp/bid-non-canonical-d32-2.c,
gcc.dg/dfp/bid-non-canonical-d64-1.c,
gcc.dg/dfp/bid-non-canonical-d64-2.c: New tests.

From-SVN: r279129
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/dfp/bid-non-canonical-d128-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/bid-non-canonical-d128-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/bid-non-canonical-d128-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/bid-non-canonical-d128-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/bid-non-canonical-d32-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/bid-non-canonical-d32-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/bid-non-canonical-d64-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/bid-non-canonical-d64-2.c [new file with mode: 0644]
libdecnumber/ChangeLog
libdecnumber/bid/bid2dpd_dpd2bid.c
This page took 0.057247 seconds and 5 git commands to generate.