[Gmp-commit] /var/hg/gmp: 2 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Sun Mar 13 20:15:37 CET 2011


details:   /var/hg/gmp/rev/865bc368e2e1
changeset: 14053:865bc368e2e1
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Mar 13 20:15:20 2011 +0100
description:
Improve MPN_IORD_U.

details:   /var/hg/gmp/rev/256f0cd18cb7
changeset: 14054:256f0cd18cb7
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Mar 13 20:15:28 2011 +0100
description:
*** empty log message ***

diffstat:

 ChangeLog  |   5 +++++
 gmp-impl.h |  36 +++++++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 13 deletions(-)

diffs (83 lines):

diff -r 5671fbcbf6c4 -r 256f0cd18cb7 ChangeLog
--- a/ChangeLog	Sat Mar 12 22:38:49 2011 +0100
+++ b/ChangeLog	Sun Mar 13 20:15:28 2011 +0100
@@ -1,3 +1,8 @@
+2011-03-13  Torbjorn Granlund  <tege at gmplib.org>
+
+	* gmp-impl.h (MPN_IORD_U): Handle x86_64 as well as x86_32.  Generate
+	no code for incrementing by constant 0.
+
 2011-03-12  Marc Glisse  <marc.glisse at inria.fr>
 
 	* gmpxx.h: Rename __GMPXX_TMP_* to __GMPXX_TMPZ_*. Use in more places.
diff -r 5671fbcbf6c4 -r 256f0cd18cb7 gmp-impl.h
--- a/gmp-impl.h	Sat Mar 12 22:38:49 2011 +0100
+++ b/gmp-impl.h	Sun Mar 13 20:15:28 2011 +0100
@@ -2389,44 +2389,54 @@
    declaring their operand sizes, then remove the former.  This is purely
    for the benefit of assertion checking.  */
 
-#if defined (__GNUC__) && HAVE_HOST_CPU_FAMILY_x86 && GMP_NAIL_BITS == 0      \
-  && GMP_LIMB_BITS == 32 && ! defined (NO_ASM) && ! WANT_ASSERT
+#if defined (__GNUC__) && GMP_NAIL_BITS == 0 && ! defined (NO_ASM)	\
+  && (defined(HAVE_HOST_CPU_FAMILY_x86) || defined(HAVE_HOST_CPU_FAMILY_x86_64)) \
+  && ! WANT_ASSERT
 /* Better flags handling than the generic C gives on i386, saving a few
    bytes of code and maybe a cycle or two.  */
 
 #define MPN_IORD_U(ptr, incr, aors)					\
   do {									\
     mp_ptr  __ptr_dummy;						\
-    if (__builtin_constant_p (incr) && (incr) == 1)			\
+    if (__builtin_constant_p (incr) && (incr) == 0)			\
+      {									\
+      }									\
+    else if (__builtin_constant_p (incr) && (incr) == 1)		\
       {									\
         __asm__ __volatile__						\
           ("\n" ASM_L(top) ":\n"					\
-           "\t" aors " $1, (%0)\n"					\
-           "\tleal 4(%0),%0\n"						\
-           "\tjc " ASM_L(top)						\
+           "\t" aors "\t$1, (%0)\n"					\
+           "\tlea\t%c2(%0), %0\n"					\
+           "\tjc\t" ASM_L(top)						\
            : "=r" (__ptr_dummy)						\
-           : "0"  (ptr)							\
+           : "0"  (ptr), "n" (sizeof(mp_limb_t))			\
            : "memory");							\
       }									\
     else								\
       {									\
         __asm__ __volatile__						\
-          (   aors  " %2,(%0)\n"					\
-           "\tjnc " ASM_L(done) "\n"					\
+          (   aors  "\t%2, (%0)\n"					\
+           "\tjnc\t" ASM_L(done) "\n"					\
            ASM_L(top) ":\n"						\
-           "\t" aors " $1,4(%0)\n"					\
-           "\tleal 4(%0),%0\n"						\
-           "\tjc " ASM_L(top) "\n"					\
+           "\t" aors "\t$1, %c3(%0)\n"					\
+           "\tlea\t%c3(%0), %0\n"					\
+           "\tjc\t" ASM_L(top) "\n"					\
            ASM_L(done) ":\n"						\
            : "=r" (__ptr_dummy)						\
            : "0"  (ptr),						\
-             "ri" (incr)						\
+             "ri" ((mp_limb_t) (incr)), "n" (sizeof(mp_limb_t))		\
            : "memory");							\
       }									\
   } while (0)
 
+#if GMP_LIMB_BITS == 32
 #define MPN_INCR_U(ptr, size, incr)  MPN_IORD_U (ptr, incr, "addl")
 #define MPN_DECR_U(ptr, size, incr)  MPN_IORD_U (ptr, incr, "subl")
+#endif
+#if GMP_LIMB_BITS == 64
+#define MPN_INCR_U(ptr, size, incr)  MPN_IORD_U (ptr, incr, "addq")
+#define MPN_DECR_U(ptr, size, incr)  MPN_IORD_U (ptr, incr, "subq")
+#endif
 #define mpn_incr_u(ptr, incr)  MPN_INCR_U (ptr, 0, incr)
 #define mpn_decr_u(ptr, incr)  MPN_DECR_U (ptr, 0, incr)
 #endif


More information about the gmp-commit mailing list