C implementation of mod_1_1

Torbjorn Granlund tg at gmplib.org
Thu Mar 3 11:44:00 CET 2011


nisse at lysator.liu.se (Niels Möller) writes:

  I've looked a bit further. It took me a good while before I found the
  doc on the % modifier in constraints. BTW, the definition of add_ssaaaa
  for sparc64 (line 1567) violates the gcc restriction that multiple %
  modifiers are not supported.
  
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.

There is no point in using it though, except when the constraint flags
are different.

    3. For powerpc, I have a strange matching constraint between s0 and a0
       (inherited from the add_sssaaaa you gave me). I can guess what the
       %I6c is intended to do, is that related? The add_ssaaaa in longlong.h
       uses some different tricks, but no matching constraint.
  
II6 generates an i if the operand is immediate.

  For x86 and x86_64, the main change is that m is now an output only, in
  earlier versions derived from add_sssaaaa it was an input/output
  operand.
  
This is good...
  
  /* 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.

  /* 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.

-- 
Torbjörn


More information about the gmp-devel mailing list