coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] factor: improve support on RISCV and loongson


From: Pádraig Brady
Subject: [PATCH] factor: improve support on RISCV and loongson
Date: Mon, 4 Apr 2022 13:44:06 +0100

* src/longlong.h: Pull in RISCV fix and loongarch64 support from
https://gmplib.org/repo/gmp/log/tip/longlong.h
---
 src/longlong.h | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/longlong.h b/src/longlong.h
index 279e6a7b3..6e279b466 100644
--- a/src/longlong.h
+++ b/src/longlong.h
@@ -1142,6 +1142,17 @@ extern UWtype __MPN(udiv_qrnnd) (UWtype *, UWtype, 
UWtype, UWtype);
 #endif /* i960mx */
 #endif /* i960 */
 
+
+#if defined (__loongarch64) && W_TYPE_SIZE == 64
+#define umul_ppmm(w1, w0, u, v) \
+  do {                                                                 \
+    UDItype __u = (u), __v = (v);                                      \
+    (w0) = __u * __v;                                                  \
+    (w1) = (unsigned __int128__) __u * __v >> 64;                      \
+  } while (0)
+#endif
+
+
 #if (defined (__mc68000__) || defined (__mc68020__) || defined(mc68020) \
      || defined (__m68k__) || defined (__mc5200__) || defined (__mc5206e__) \
      || defined (__mc5307__)) && W_TYPE_SIZE == 32
@@ -1638,12 +1649,12 @@ extern UWtype __MPN(udiv_qrnnd) (UWtype *, UWtype, 
UWtype, UWtype);
   } while (0)
 #endif /* RT/ROMP */
 
-#if defined (__riscv64) && W_TYPE_SIZE == 64
+#if defined (__riscv) && defined (__riscv_mul) && W_TYPE_SIZE == 64
 #define umul_ppmm(ph, pl, u, v) \
   do {                                                                 \
     UDItype __u = (u), __v = (v);                                      \
     (pl) = __u * __v;                                                  \
-    __asm__ ("mulhu\t%2, %1, %0" : "=r" (ph) : "%r" (__u), "r" (__v)); \
+    __asm__ ("mulhu\t%0, %1, %2" : "=r" (ph) : "%r" (__u), "r" (__v)); \
   } while (0)
 #endif
 
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]