[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 33/46] softfloat: Use uadd64_carry, usub64_borrow in softfloat-mac
From: |
Richard Henderson |
Subject: |
[PULL 33/46] softfloat: Use uadd64_carry, usub64_borrow in softfloat-macros.h |
Date: |
Sun, 16 May 2021 07:34:18 -0500 |
Use compiler support for carry arithmetic.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/fpu/softfloat-macros.h | 95 +++++++++-------------------------
1 file changed, 25 insertions(+), 70 deletions(-)
diff --git a/include/fpu/softfloat-macros.h b/include/fpu/softfloat-macros.h
index a35ec2893a..2e3760a9c1 100644
--- a/include/fpu/softfloat-macros.h
+++ b/include/fpu/softfloat-macros.h
@@ -83,6 +83,7 @@ this code that are retained.
#define FPU_SOFTFLOAT_MACROS_H
#include "fpu/softfloat-types.h"
+#include "qemu/host-utils.h"
/*----------------------------------------------------------------------------
| Shifts `a' right by the number of bits given in `count'. If any nonzero
@@ -403,16 +404,12 @@ static inline void
| are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
*----------------------------------------------------------------------------*/
-static inline void
- add128(
- uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1, uint64_t *z0Ptr,
uint64_t *z1Ptr )
+static inline void add128(uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1,
+ uint64_t *z0Ptr, uint64_t *z1Ptr)
{
- uint64_t z1;
-
- z1 = a1 + b1;
- *z1Ptr = z1;
- *z0Ptr = a0 + b0 + ( z1 < a1 );
-
+ bool c = 0;
+ *z1Ptr = uadd64_carry(a1, b1, &c);
+ *z0Ptr = uadd64_carry(a0, b0, &c);
}
/*----------------------------------------------------------------------------
@@ -423,34 +420,14 @@ static inline void
| `z1Ptr', and `z2Ptr'.
*----------------------------------------------------------------------------*/
-static inline void
- add192(
- uint64_t a0,
- uint64_t a1,
- uint64_t a2,
- uint64_t b0,
- uint64_t b1,
- uint64_t b2,
- uint64_t *z0Ptr,
- uint64_t *z1Ptr,
- uint64_t *z2Ptr
- )
+static inline void add192(uint64_t a0, uint64_t a1, uint64_t a2,
+ uint64_t b0, uint64_t b1, uint64_t b2,
+ uint64_t *z0Ptr, uint64_t *z1Ptr, uint64_t *z2Ptr)
{
- uint64_t z0, z1, z2;
- int8_t carry0, carry1;
-
- z2 = a2 + b2;
- carry1 = ( z2 < a2 );
- z1 = a1 + b1;
- carry0 = ( z1 < a1 );
- z0 = a0 + b0;
- z1 += carry1;
- z0 += ( z1 < carry1 );
- z0 += carry0;
- *z2Ptr = z2;
- *z1Ptr = z1;
- *z0Ptr = z0;
-
+ bool c = 0;
+ *z2Ptr = uadd64_carry(a2, b2, &c);
+ *z1Ptr = uadd64_carry(a1, b1, &c);
+ *z0Ptr = uadd64_carry(a0, b0, &c);
}
/*----------------------------------------------------------------------------
@@ -461,14 +438,12 @@ static inline void
| `z1Ptr'.
*----------------------------------------------------------------------------*/
-static inline void
- sub128(
- uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1, uint64_t *z0Ptr,
uint64_t *z1Ptr )
+static inline void sub128(uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1,
+ uint64_t *z0Ptr, uint64_t *z1Ptr)
{
-
- *z1Ptr = a1 - b1;
- *z0Ptr = a0 - b0 - ( a1 < b1 );
-
+ bool c = 0;
+ *z1Ptr = usub64_borrow(a1, b1, &c);
+ *z0Ptr = usub64_borrow(a0, b0, &c);
}
/*----------------------------------------------------------------------------
@@ -479,34 +454,14 @@ static inline void
| pointed to by `z0Ptr', `z1Ptr', and `z2Ptr'.
*----------------------------------------------------------------------------*/
-static inline void
- sub192(
- uint64_t a0,
- uint64_t a1,
- uint64_t a2,
- uint64_t b0,
- uint64_t b1,
- uint64_t b2,
- uint64_t *z0Ptr,
- uint64_t *z1Ptr,
- uint64_t *z2Ptr
- )
+static inline void sub192(uint64_t a0, uint64_t a1, uint64_t a2,
+ uint64_t b0, uint64_t b1, uint64_t b2,
+ uint64_t *z0Ptr, uint64_t *z1Ptr, uint64_t *z2Ptr)
{
- uint64_t z0, z1, z2;
- int8_t borrow0, borrow1;
-
- z2 = a2 - b2;
- borrow1 = ( a2 < b2 );
- z1 = a1 - b1;
- borrow0 = ( a1 < b1 );
- z0 = a0 - b0;
- z0 -= ( z1 < borrow1 );
- z1 -= borrow1;
- z0 -= borrow0;
- *z2Ptr = z2;
- *z1Ptr = z1;
- *z0Ptr = z0;
-
+ bool c = 0;
+ *z2Ptr = usub64_borrow(a2, b2, &c);
+ *z1Ptr = usub64_borrow(a1, b1, &c);
+ *z0Ptr = usub64_borrow(a0, b0, &c);
}
/*----------------------------------------------------------------------------
--
2.25.1
- [PULL 11/46] softfloat: Use return_nan in float_to_float, (continued)
- [PULL 11/46] softfloat: Use return_nan in float_to_float, Richard Henderson, 2021/05/16
- [PULL 13/46] target/mips: Set set_default_nan_mode with set_snan_bit_is_one, Richard Henderson, 2021/05/16
- [PULL 16/46] softfloat: Move type-specific pack/unpack routines, Richard Henderson, 2021/05/16
- [PULL 14/46] softfloat: Do not produce a default_nan from parts_silence_nan, Richard Henderson, 2021/05/16
- [PULL 15/46] softfloat: Rename FloatParts to FloatParts64, Richard Henderson, 2021/05/16
- [PULL 20/46] softfloat: Use pointers with pack_raw, Richard Henderson, 2021/05/16
- [PULL 23/46] softfloat: Use pointers with ftype_round_pack_canonical, Richard Henderson, 2021/05/16
- [PULL 12/46] softfloat: fix return_nan vs default_nan_mode, Richard Henderson, 2021/05/16
- [PULL 17/46] softfloat: Use pointers with parts_default_nan, Richard Henderson, 2021/05/16
- [PULL 29/46] softfloat: Move pick_nan to softfloat-parts.c.inc, Richard Henderson, 2021/05/16
- [PULL 33/46] softfloat: Use uadd64_carry, usub64_borrow in softfloat-macros.h,
Richard Henderson <=
- [PULL 18/46] softfloat: Use pointers with unpack_raw, Richard Henderson, 2021/05/16
- [PULL 19/46] softfloat: Use pointers with ftype_unpack_raw, Richard Henderson, 2021/05/16
- [PULL 07/46] softfloat: Inline float_raise, Richard Henderson, 2021/05/16
- [PULL 31/46] softfloat: Move sf_canonicalize to softfloat-parts.c.inc, Richard Henderson, 2021/05/16
- [PULL 22/46] softfloat: Use pointers with ftype_unpack_canonical, Richard Henderson, 2021/05/16
- [PULL 26/46] softfloat: Convert float128_silence_nan to parts, Richard Henderson, 2021/05/16
- [PULL 25/46] softfloat: Rearrange FloatParts64, Richard Henderson, 2021/05/16
- [PULL 24/46] softfloat: Use pointers with parts_silence_nan, Richard Henderson, 2021/05/16
- [PULL 28/46] softfloat: Move return_nan to softfloat-parts.c.inc, Richard Henderson, 2021/05/16
- [PULL 21/46] softfloat: Use pointers with ftype_pack_raw, Richard Henderson, 2021/05/16