C implementation of mod_1_1
Torbjorn Granlund
tg at gmplib.org
Thu Mar 3 12:16:58 CET 2011
Torbjorn Granlund <tg at gmplib.org> writes:
/* FIXME: Needs review and/or testing. */
#if 0 && defined (__sparc__) && W_TYPE_SIZE == 64
#define add_mssaaaa(m, sh, sl, ah, al, bh, bl) \
__asm__ ( \
"addcc %r5,%6,%2\n" \
" addccc %r7,%8,%%g0\n" \
" addc %r3,%4,%1\n" \
" clr %0\n" \
" movcs %%xcc, -1, %0\n" \
: "=r" (m),"=r" (sh), "=&r" (sl) \
: "rJ" (ah), "rI" (bh), "%rJ" (al), "rI" (bl), \
"rJ" ((al) >> 32), "rI" ((bl) >> 32), \
__CLOBBER_CC)
#endif
I cannot see how carry-out from ah.bh works.
Sorry, I am confused. If addc means eat carry from icc and generate
carry to xcc, themn the code is probably correct.
I find it best to test these types of things before staring too much at
them.
/* FIXME: Needs review and/or testing. I don't understand why
constraints says s0 (%2) and a0 (%6) must share a register. */
#if 0 && HAVE_HOST_CPU_FAMILY_powerpc && W_TYPE_SIZE == 64
#define add_mssaaaa(m, s1, s0, a1, a0, b1, b0) \
__asm__ ( \
"add%I6c %2,%5,%6\n" \
" adde %1,%3,%4\n" \
" subfe %0,%0,%0\n" \
" neg %0, %0" \
: "=r" (m), "=r" (s1), "=&r" (s0) \
: "r" ((UDItype)(a1)), "r" ((UDItype)(b1)), \
"%2" ((UDItype)(a0)), "rI" ((UDItype)(b0)))
#endif
This cannot be right. Replace the neg with a subfi %0,%0,-1.
Clarification: subtract-with-carry on ppc processors complement the
subtrahend, and add the carry flag and minuend to that. I.e., CF=1
means no carry.
The binding 5->2 looks bogus. The comment about 6->2 is wrong...
--
Torbjörn
More information about the gmp-devel
mailing list