diff mbox series

[1/8] softfloat: Use mulu64 for mul64To128

Message ID 20200924012453.659757-2-richard.henderson@linaro.org
State Superseded
Headers show
Series softfloat: Implement float128_muladd | expand

Commit Message

Richard Henderson Sept. 24, 2020, 1:24 a.m. UTC
Via host-utils.h, we use a host widening multiply for
64-bit hosts, and a common subroutine for 32-bit hosts.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/fpu/softfloat-macros.h | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

Comments

David Hildenbrand Sept. 24, 2020, 7:32 a.m. UTC | #1
On 24.09.20 03:24, Richard Henderson wrote:
> Via host-utils.h, we use a host widening multiply for
> 64-bit hosts, and a common subroutine for 32-bit hosts.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  include/fpu/softfloat-macros.h | 24 ++++--------------------
>  1 file changed, 4 insertions(+), 20 deletions(-)
> 
> diff --git a/include/fpu/softfloat-macros.h b/include/fpu/softfloat-macros.h
> index a35ec2893a..57845f8af0 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
> @@ -515,27 +516,10 @@ static inline void
>  | `z0Ptr' and `z1Ptr'.
>  *----------------------------------------------------------------------------*/
>  
> -static inline void mul64To128( uint64_t a, uint64_t b, uint64_t *z0Ptr, uint64_t *z1Ptr )
> +static inline void
> +mul64To128(uint64_t a, uint64_t b, uint64_t *z0Ptr, uint64_t *z1Ptr)
>  {
> -    uint32_t aHigh, aLow, bHigh, bLow;
> -    uint64_t z0, zMiddleA, zMiddleB, z1;
> -
> -    aLow = a;
> -    aHigh = a>>32;
> -    bLow = b;
> -    bHigh = b>>32;
> -    z1 = ( (uint64_t) aLow ) * bLow;
> -    zMiddleA = ( (uint64_t) aLow ) * bHigh;
> -    zMiddleB = ( (uint64_t) aHigh ) * bLow;
> -    z0 = ( (uint64_t) aHigh ) * bHigh;
> -    zMiddleA += zMiddleB;
> -    z0 += ( ( (uint64_t) ( zMiddleA < zMiddleB ) )<<32 ) + ( zMiddleA>>32 );
> -    zMiddleA <<= 32;
> -    z1 += zMiddleA;
> -    z0 += ( z1 < zMiddleA );
> -    *z1Ptr = z1;
> -    *z0Ptr = z0;
> -
> +    mulu64(z1Ptr, z0Ptr, a, b);
>  }
>  
>  /*----------------------------------------------------------------------------
> 

Reviewed-by: David Hildenbrand <david@redhat.com>
diff mbox series

Patch

diff --git a/include/fpu/softfloat-macros.h b/include/fpu/softfloat-macros.h
index a35ec2893a..57845f8af0 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
@@ -515,27 +516,10 @@  static inline void
 | `z0Ptr' and `z1Ptr'.
 *----------------------------------------------------------------------------*/
 
-static inline void mul64To128( uint64_t a, uint64_t b, uint64_t *z0Ptr, uint64_t *z1Ptr )
+static inline void
+mul64To128(uint64_t a, uint64_t b, uint64_t *z0Ptr, uint64_t *z1Ptr)
 {
-    uint32_t aHigh, aLow, bHigh, bLow;
-    uint64_t z0, zMiddleA, zMiddleB, z1;
-
-    aLow = a;
-    aHigh = a>>32;
-    bLow = b;
-    bHigh = b>>32;
-    z1 = ( (uint64_t) aLow ) * bLow;
-    zMiddleA = ( (uint64_t) aLow ) * bHigh;
-    zMiddleB = ( (uint64_t) aHigh ) * bLow;
-    z0 = ( (uint64_t) aHigh ) * bHigh;
-    zMiddleA += zMiddleB;
-    z0 += ( ( (uint64_t) ( zMiddleA < zMiddleB ) )<<32 ) + ( zMiddleA>>32 );
-    zMiddleA <<= 32;
-    z1 += zMiddleA;
-    z0 += ( z1 < zMiddleA );
-    *z1Ptr = z1;
-    *z0Ptr = z0;
-
+    mulu64(z1Ptr, z0Ptr, a, b);
 }
 
 /*----------------------------------------------------------------------------