Re: [PATCH] Update libbid according to the latest Intel Decimal Floating-Point Math Library.
On Sun, Apr 28, 2024 at 7:53 AM liuhongt wrote: > > The Intel Decimal Floating-Point Math Library is available as open-source on > Netlib[1]. > > [1] https://www.netlib.org/misc/intel/. > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > Ok for trunk? OK for trunk. Thanks, Richard. > libgcc/config/libbid/ChangeLog: > > * bid128_fma.c (add_and_round): Fix bug: the result > of (+5E+368)*(+10E-34)+(-10E+369) was returning > -99E+336 instead of expected > result -10E+337. > (bid128_ext_fma): Ditto. > (bid64qqq_fma): Ditto. > * bid128_noncomp.c: Change return type of bid128_class from > int to class_t. > * bid128_round_integral.c: Add default case to avoid compiler > warning. > * bid128_string.c (bid128_to_string): Replace 0x30 with '0' > for zero digit. > (bid128_from_string): Ditto. > * bid32_to_bid128.c (bid128_to_bid32): Fix Bug. In addition > to the INEXACT flag, the UNDERFLOW flag needs to be set (and > was not) when converting an input such as > +6931674235302037148946035460357709E+1857 to +100E-101 > * bid32_to_bid64.c (bid64_to_bid32): fix Bug, In addition to > the INEXACT flag, the UNDERFLOW flag needs to be set (and was > not) when converting an input such as +9991E-111 > to +100E-101. Furthermore, significant bits of NaNs are > set correctly now. For example, 0x7c3b9aca was > returning 0x7c02 instead of 0x 7c000100. > * bid64_noncomp.c: Change return type of bid64_class from int > to class_t. > * bid64_round_integral.c (bid64_round_integral_exact): Add > default case to avoid compiler warning. > * bid64_string.c (bid64_from_string): Fix bug for rounding > up. The input string "1" was returning > +1001E+1 instead of +1000E+1. > * bid64_to_bid128.c (bid128_to_bid64): Fix bug, in addition to > the INEXACT flag, the UNDERFLOW flag needs to be set (and was > not) when converting an input such as > +99E-417 to > +1000E-398. > * bid_binarydecimal.c (bid32_to_binary64): Fix bug for > conversion between binary and bid types. For example, > 0x7c0F4240 was returning 0x7FFFA120 instead of > expected double precision 0x7FF8. > (binary64_to_bid32): Ditto. > (binary80_to_bid32): Ditto. > (binary128_to_bid32): Ditto. > (binary80_to_bid64): Ditto. > (binary128_to_bid64): Ditto. > * bid_conf.h (BID_HIGH_128W): New macro. > (BID_LOW_128W): Ditto. > * bid_functions.h (__ENABLE_BINARY80__): Ditto. > (ALIGN): Ditto. > * bid_inline_add.h (get_add128): Add default case to avoid compiler > warning. > * bid_internal.h (get_BID64): Ditto. > (fast_get_BID64_check_OF): Ditto. > (ALIGN): New macro. > > Co-authored-by: Anderson, Cristina S > Co-authored-by: Akkas, Ahmet > Co-authored-by: Cornea, Marius > --- > libgcc/config/libbid/bid128_fma.c| 188 ++- > libgcc/config/libbid/bid128_noncomp.c| 2 +- > libgcc/config/libbid/bid128_round_integral.c | 2 + > libgcc/config/libbid/bid128_string.c | 7 +- > libgcc/config/libbid/bid32_to_bid128.c | 3 - > libgcc/config/libbid/bid32_to_bid64.c| 11 +- > libgcc/config/libbid/bid64_noncomp.c | 2 +- > libgcc/config/libbid/bid64_round_integral.c | 2 + > libgcc/config/libbid/bid64_string.c | 21 ++- > libgcc/config/libbid/bid64_to_bid128.c | 3 - > libgcc/config/libbid/bid_binarydecimal.c | 167 ++-- > libgcc/config/libbid/bid_conf.h | 8 + > libgcc/config/libbid/bid_functions.h | 23 ++- > libgcc/config/libbid/bid_inline_add.h| 2 + > libgcc/config/libbid/bid_internal.h | 17 +- > 15 files changed, 220 insertions(+), 238 deletions(-) > > diff --git a/libgcc/config/libbid/bid128_fma.c > b/libgcc/config/libbid/bid128_fma.c > index 67233193a42..cbcf225546f 100644 > --- a/libgcc/config/libbid/bid128_fma.c > +++ b/libgcc/config/libbid/bid128_fma.c > @@ -417,13 +417,12 @@ add_and_round (int q3, >R128.w[1] = R256.w[1]; >R128.w[0] = R256.w[0]; > } > +if (e4 + x0 < expmin) { // for all rounding modes > + is_tiny = 1; > +} > // the rounded result has p34 = 34 digits > e4 = e4 + x0 + incr_exp; > -if (rnd_mode == ROUNDING_TO_NEAREST) { > - if (e4 < expmin) { > -is_tiny = 1; // for other rounding modes apply correction > - } > -} else { > +if (rnd_mode != ROUNDING_TO_NEAREST) { >// for RM, RP, RZ, RA apply
[PATCH] Update libbid according to the latest Intel Decimal Floating-Point Math Library.
The Intel Decimal Floating-Point Math Library is available as open-source on Netlib[1]. [1] https://www.netlib.org/misc/intel/. Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ok for trunk? libgcc/config/libbid/ChangeLog: * bid128_fma.c (add_and_round): Fix bug: the result of (+5E+368)*(+10E-34)+(-10E+369) was returning -99E+336 instead of expected result -10E+337. (bid128_ext_fma): Ditto. (bid64qqq_fma): Ditto. * bid128_noncomp.c: Change return type of bid128_class from int to class_t. * bid128_round_integral.c: Add default case to avoid compiler warning. * bid128_string.c (bid128_to_string): Replace 0x30 with '0' for zero digit. (bid128_from_string): Ditto. * bid32_to_bid128.c (bid128_to_bid32): Fix Bug. In addition to the INEXACT flag, the UNDERFLOW flag needs to be set (and was not) when converting an input such as +6931674235302037148946035460357709E+1857 to +100E-101 * bid32_to_bid64.c (bid64_to_bid32): fix Bug, In addition to the INEXACT flag, the UNDERFLOW flag needs to be set (and was not) when converting an input such as +9991E-111 to +100E-101. Furthermore, significant bits of NaNs are set correctly now. For example, 0x7c3b9aca was returning 0x7c02 instead of 0x 7c000100. * bid64_noncomp.c: Change return type of bid64_class from int to class_t. * bid64_round_integral.c (bid64_round_integral_exact): Add default case to avoid compiler warning. * bid64_string.c (bid64_from_string): Fix bug for rounding up. The input string "1" was returning +1001E+1 instead of +1000E+1. * bid64_to_bid128.c (bid128_to_bid64): Fix bug, in addition to the INEXACT flag, the UNDERFLOW flag needs to be set (and was not) when converting an input such as +99E-417 to +1000E-398. * bid_binarydecimal.c (bid32_to_binary64): Fix bug for conversion between binary and bid types. For example, 0x7c0F4240 was returning 0x7FFFA120 instead of expected double precision 0x7FF8. (binary64_to_bid32): Ditto. (binary80_to_bid32): Ditto. (binary128_to_bid32): Ditto. (binary80_to_bid64): Ditto. (binary128_to_bid64): Ditto. * bid_conf.h (BID_HIGH_128W): New macro. (BID_LOW_128W): Ditto. * bid_functions.h (__ENABLE_BINARY80__): Ditto. (ALIGN): Ditto. * bid_inline_add.h (get_add128): Add default case to avoid compiler warning. * bid_internal.h (get_BID64): Ditto. (fast_get_BID64_check_OF): Ditto. (ALIGN): New macro. Co-authored-by: Anderson, Cristina S Co-authored-by: Akkas, Ahmet Co-authored-by: Cornea, Marius --- libgcc/config/libbid/bid128_fma.c| 188 ++- libgcc/config/libbid/bid128_noncomp.c| 2 +- libgcc/config/libbid/bid128_round_integral.c | 2 + libgcc/config/libbid/bid128_string.c | 7 +- libgcc/config/libbid/bid32_to_bid128.c | 3 - libgcc/config/libbid/bid32_to_bid64.c| 11 +- libgcc/config/libbid/bid64_noncomp.c | 2 +- libgcc/config/libbid/bid64_round_integral.c | 2 + libgcc/config/libbid/bid64_string.c | 21 ++- libgcc/config/libbid/bid64_to_bid128.c | 3 - libgcc/config/libbid/bid_binarydecimal.c | 167 ++-- libgcc/config/libbid/bid_conf.h | 8 + libgcc/config/libbid/bid_functions.h | 23 ++- libgcc/config/libbid/bid_inline_add.h| 2 + libgcc/config/libbid/bid_internal.h | 17 +- 15 files changed, 220 insertions(+), 238 deletions(-) diff --git a/libgcc/config/libbid/bid128_fma.c b/libgcc/config/libbid/bid128_fma.c index 67233193a42..cbcf225546f 100644 --- a/libgcc/config/libbid/bid128_fma.c +++ b/libgcc/config/libbid/bid128_fma.c @@ -417,13 +417,12 @@ add_and_round (int q3, R128.w[1] = R256.w[1]; R128.w[0] = R256.w[0]; } +if (e4 + x0 < expmin) { // for all rounding modes + is_tiny = 1; +} // the rounded result has p34 = 34 digits e4 = e4 + x0 + incr_exp; -if (rnd_mode == ROUNDING_TO_NEAREST) { - if (e4 < expmin) { -is_tiny = 1; // for other rounding modes apply correction - } -} else { +if (rnd_mode != ROUNDING_TO_NEAREST) { // for RM, RP, RZ, RA apply correction in order to determine tininess // but do not save the result; apply the correction to // (-1)^p_sign * significand * 10^0 @@ -434,10 +433,6 @@ add_and_round (int q3, is_inexact_gt_midpoint, is_midpoint_lt_even,