[PATCH v2 04/32] mpi: Use the SPARC V8 umul_ppmm and udiv_qrnnd for V9.
Matt Turner
mattst88 at gmail.com
Wed Nov 25 21:19:41 CET 2026
* mpi/longlong.h [__sparc__] (umul_ppmm, udiv_qrnnd): Use the V8
versions when __sparc_v9__ is defined. Update the #else and #endif
comments.
--
GCC and clang define only __sparc_v9__, not __sparc_v8__, for 32-bit
code built with -mcpu=v9 or a later CPU, so such builds fall back to the
V7 mulscc loop for umul_ppmm and to the out-of-line __udiv_qrnnd, even
though the CPU has umul and udiv. The sparc9 and ultrasparc
configurations in mpi/config.links do not build mpi/sparc32/udiv.S,
which is the only definition of __udiv_qrnnd, so those builds are
left with an undefined reference to it.
GCC's copy of longlong.h has a separate V9 path (commit 0de0d5c6062,
"Sparc longlong.h enhancements") whose umul_ppmm takes the 64-bit
product from %g1 with srlx. Clang's assembler rejects srlx in 32-bit
code, so use the V8 versions, which assemble with both compilers.
Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
mpi/longlong.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mpi/longlong.h b/mpi/longlong.h
index c10abddf..685e26e0 100644
--- a/mpi/longlong.h
+++ b/mpi/longlong.h
@@ -1065,7 +1065,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
"rJ" ((USItype)(al)), \
"rI" ((USItype)(bl)) \
__CLOBBER_CC)
-# if defined (__sparc_v8__) || defined(__sparcv8)
+# if defined (__sparc_v8__) || defined(__sparcv8) || defined (__sparc_v9__)
/* Don't match immediate range because, 1) it is not often useful,
2) the 'I' flag thinks of the range as a 13 bit signed interval,
while we want to match a 13 bit interval, sign extended to 32 bits,
@@ -1091,7 +1091,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
} while (0)
# define UDIV_TIME 25
# endif /*!SUPERSPARC */
-# else /* ! __sparc_v8__ */
+# else /* ! __sparc_v8__ && ! __sparc_v9__ */
# if defined (__sparclite__)
/* This has hardware multiply but not divide. It also has two additional
instructions scan (ffs from high bit) and divscc. */
@@ -1157,7 +1157,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
implementations might change this. Therefore, leave COUNT_LEADING_ZEROS_0
undefined. */
# endif /* !__sparclite__ */
-# endif /* !__sparc_v8__ */
+# endif /* ! __sparc_v8__ && ! __sparc_v9__ */
/* Default to sparc v7 versions of umul_ppmm and udiv_qrnnd. */
# ifndef umul_ppmm
# define umul_ppmm(w1, w0, u, v) \
--
2.56.1
More information about the Gcrypt-devel
mailing list