C implementation of mod_1_1
Torbjorn Granlund
tg at gmplib.org
Thu Mar 3 17:11:14 CET 2011
nisse at lysator.liu.se (Niels Möller) writes:
> Yep, but it also does not do any harm. GCC simply ignores aditional
> such claims of commutative after the initial one. If GCC someday is
> improved, fine.
Both gcc documentation and comments on longlong.h claim that multiple %
can make gcc fail...
Oh, then perhaps we should avoid using that.
> /* 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.
Hmm, the final addc should be an addccc. Does it look corrrect then?
I had to look the manual, and yes, the 3 'c' variant should be used there.
This mask must be complemented, subfic %0,%0,-1 should be the same as
nor %0,%0,%0 (except for the effect on the carry out). And I see only
subfic in the docs, not subfi, but it doesn't matter since we've
clobbered the carry flag anyway. (Hmm, on powerpc we don't need any
explicit clobber statement for the carry?)
Then use 'nor', not 'subfic'. (addc, addic, subfic, subfc are cracked
into two internal insns on POWER4 and PPC979, therefore to be avoided.)
And what about the constraint
"%2" ((UDItype)(a0))
is that really needed, and why? It says that a0 input and s0 output must
be put in the same register.
>From which file did you get this? Not longlong.h?
--
Torbjörn
More information about the gmp-devel
mailing list