GMP-5.0.0 problems with gcd_1.asm on Apple with fixes

Torbjorn Granlund tg at gmplib.org
Tue Jan 12 22:59:42 CET 2010


Thanks Philip for your feedback!

  >> Fix #1: this error vanishes if the trailing zero table label "L(table)" is changed to "tz_table" (2 places).
  
What is the logic behind this change?

I worry about this LEA reference.

If you compile a corresponding C file, with a reference to a

  const static int foo[10] = {1,2,3,4,5,6,7,8,9,10};

using both PIC and non-PIC code, what does the refenece look like?

  2) After fix #1, "make check" fails in "t-fat" with a segmentation fault at the call to test "mpn_gcd_1".
  
  >> Fix #2: the fix for this error was suggested in the file "redc_1.asm", where the stack pointer
                    needs to be aligned for a secondary call. Adding the instruction
  
  		sub	$8, %rsp                   C maintain ABI required rsp alignment
   
  just before the instruction
  
  		CALL(	mpn_modexact_1_odd)
  
  which is then followed by
  
  		add	$8, %rsp
  
  fixes the fault and "make check" runs without errors.
  
OK.

  3) (Bonus code improvement!) Near the start of the routine, the instructions
  
  		mov	%r8, %r10
  		...
  and
  
  		shr	R8(%rcx), %r10
   
  can be removed. r10 is not used before it is overwritten elsewhere.
  
You're right!  (My flow analysis was apparently somewhat simple-minded
when I wrote this file.)

-- 
Torbjörn


More information about the gmp-bugs mailing list