[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 61/72] softfloat: Convert floatx80_div to FloatParts
From: |
Richard Henderson |
Subject: |
[PATCH 61/72] softfloat: Convert floatx80_div to FloatParts |
Date: |
Fri, 7 May 2021 18:47:51 -0700 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
fpu/softfloat.c | 100 +++++++-----------------------------------------
1 file changed, 13 insertions(+), 87 deletions(-)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 4454219f8a..352f359bc5 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -2293,6 +2293,19 @@ float128_div(float128 a, float128 b, float_status
*status)
return float128_round_pack_canonical(pr, status);
}
+floatx80 floatx80_div(floatx80 a, floatx80 b, float_status *status)
+{
+ FloatParts128 pa, pb, *pr;
+
+ if (!floatx80_unpack_canonical(&pa, a, status) ||
+ !floatx80_unpack_canonical(&pb, b, status)) {
+ return floatx80_default_nan(status);
+ }
+
+ pr = parts_div(&pa, &pb, status);
+ return floatx80_round_pack_canonical(pr, status);
+}
+
/*
* Float to Float conversions
*
@@ -5879,93 +5892,6 @@ floatx80 floatx80_round_to_int(floatx80 a, float_status
*status)
}
-/*----------------------------------------------------------------------------
-| Returns the result of dividing the extended double-precision floating-point
-| value `a' by the corresponding value `b'. The operation is performed
-| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
-*----------------------------------------------------------------------------*/
-
-floatx80 floatx80_div(floatx80 a, floatx80 b, float_status *status)
-{
- bool aSign, bSign, zSign;
- int32_t aExp, bExp, zExp;
- uint64_t aSig, bSig, zSig0, zSig1;
- uint64_t rem0, rem1, rem2, term0, term1, term2;
-
- if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b)) {
- float_raise(float_flag_invalid, status);
- return floatx80_default_nan(status);
- }
- aSig = extractFloatx80Frac( a );
- aExp = extractFloatx80Exp( a );
- aSign = extractFloatx80Sign( a );
- bSig = extractFloatx80Frac( b );
- bExp = extractFloatx80Exp( b );
- bSign = extractFloatx80Sign( b );
- zSign = aSign ^ bSign;
- if ( aExp == 0x7FFF ) {
- if ((uint64_t)(aSig << 1)) {
- return propagateFloatx80NaN(a, b, status);
- }
- if ( bExp == 0x7FFF ) {
- if ((uint64_t)(bSig << 1)) {
- return propagateFloatx80NaN(a, b, status);
- }
- goto invalid;
- }
- return packFloatx80(zSign, floatx80_infinity_high,
- floatx80_infinity_low);
- }
- if ( bExp == 0x7FFF ) {
- if ((uint64_t)(bSig << 1)) {
- return propagateFloatx80NaN(a, b, status);
- }
- return packFloatx80( zSign, 0, 0 );
- }
- if ( bExp == 0 ) {
- if ( bSig == 0 ) {
- if ( ( aExp | aSig ) == 0 ) {
- invalid:
- float_raise(float_flag_invalid, status);
- return floatx80_default_nan(status);
- }
- float_raise(float_flag_divbyzero, status);
- return packFloatx80(zSign, floatx80_infinity_high,
- floatx80_infinity_low);
- }
- normalizeFloatx80Subnormal( bSig, &bExp, &bSig );
- }
- if ( aExp == 0 ) {
- if ( aSig == 0 ) return packFloatx80( zSign, 0, 0 );
- normalizeFloatx80Subnormal( aSig, &aExp, &aSig );
- }
- zExp = aExp - bExp + 0x3FFE;
- rem1 = 0;
- if ( bSig <= aSig ) {
- shift128Right( aSig, 0, 1, &aSig, &rem1 );
- ++zExp;
- }
- zSig0 = estimateDiv128To64( aSig, rem1, bSig );
- mul64To128( bSig, zSig0, &term0, &term1 );
- sub128( aSig, rem1, term0, term1, &rem0, &rem1 );
- while ( (int64_t) rem0 < 0 ) {
- --zSig0;
- add128( rem0, rem1, 0, bSig, &rem0, &rem1 );
- }
- zSig1 = estimateDiv128To64( rem1, 0, bSig );
- if ( (uint64_t) ( zSig1<<1 ) <= 8 ) {
- mul64To128( bSig, zSig1, &term1, &term2 );
- sub128( rem1, 0, term1, term2, &rem1, &rem2 );
- while ( (int64_t) rem1 < 0 ) {
- --zSig1;
- add128( rem1, rem2, 0, bSig, &rem1, &rem2 );
- }
- zSig1 |= ( ( rem1 | rem2 ) != 0 );
- }
- return roundAndPackFloatx80(status->floatx80_rounding_precision,
- zSign, zExp, zSig0, zSig1, status);
-}
-
/*----------------------------------------------------------------------------
| Returns the remainder of the extended double-precision floating-point value
| `a' with respect to the corresponding value `b'. The operation is performed
--
2.25.1
- [PATCH 60/72] softfloat: Convert floatx80_mul to FloatParts, (continued)
- [PATCH 60/72] softfloat: Convert floatx80_mul to FloatParts, Richard Henderson, 2021/05/07
- [PATCH 62/72] softfloat: Convert floatx80_sqrt to FloatParts, Richard Henderson, 2021/05/07
- [PATCH 57/72] softfloat: Adjust parts_uncanon_normal for floatx80, Richard Henderson, 2021/05/07
- [PATCH 65/72] softfloat: Convert integer to floatx80 to FloatParts, Richard Henderson, 2021/05/07
- [PATCH 68/72] softfloat: Convert floatx80_scalbn to FloatParts, Richard Henderson, 2021/05/07
- [PATCH 66/72] softfloat: Convert floatx80 float conversions to FloatParts, Richard Henderson, 2021/05/07
- [PATCH 70/72] softfloat: Convert float32_exp2 to FloatParts, Richard Henderson, 2021/05/07
- [PATCH 55/72] softfloat: Reduce FloatFmt, Richard Henderson, 2021/05/07
- [PATCH 58/72] tests/fp/fp-test: Reverse order of floatx80 precision tests, Richard Henderson, 2021/05/07
- [PATCH 61/72] softfloat: Convert floatx80_div to FloatParts,
Richard Henderson <=
- [PATCH 59/72] softfloat: Convert floatx80_add/sub to FloatParts, Richard Henderson, 2021/05/07
- [PATCH 71/72] softfloat: Move floatN_log2 to softfloat-parts.c.inc, Richard Henderson, 2021/05/07
- [PATCH 56/72] softfloat: Introduce Floatx80RoundPrec, Richard Henderson, 2021/05/07
- [PATCH 63/72] softfloat: Convert floatx80_round to FloatParts, Richard Henderson, 2021/05/07
- [PATCH 64/72] softfloat: Convert floatx80_round_to_int to FloatParts, Richard Henderson, 2021/05/07
- [PATCH 69/72] softfloat: Convert floatx80 compare to FloatParts, Richard Henderson, 2021/05/07
- [PATCH 67/72] softfloat: Convert floatx80 to integer to FloatParts, Richard Henderson, 2021/05/07
- [PATCH 72/72] softfloat: Convert modrem operations to FloatParts, Richard Henderson, 2021/05/07
- Re: [PATCH 00/72] Convert floatx80 and float128 to FloatParts, no-reply, 2021/05/07
- Re: [PATCH 00/72] Convert floatx80 and float128 to FloatParts, Alex Bennée, 2021/05/10