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

mercurial at gmplib.org mercurial at gmplib.org
Tue Aug 25 18:31:39 UTC 2015


details:   /var/hg/gmp/rev/7e6e7dafd25c
changeset: 16789:7e6e7dafd25c
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Tue Aug 25 20:23:35 2015 +0200
description:
mpf/cmp.c: Remove uneeded branches.

details:   /var/hg/gmp/rev/1052f8b7b7e2
changeset: 16790:1052f8b7b7e2
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Tue Aug 25 20:24:19 2015 +0200
description:
mpf/cmp.c: Use macros.

details:   /var/hg/gmp/rev/96c2d3d6be92
changeset: 16791:96c2d3d6be92
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Tue Aug 25 20:25:30 2015 +0200
description:
ChangeLog

diffstat:

 ChangeLog |   2 ++
 mpf/cmp.c |  45 +++++++++++++++++++++------------------------
 2 files changed, 23 insertions(+), 24 deletions(-)

diffs (104 lines):

diff -r 7121e1053956 -r 96c2d3d6be92 ChangeLog
--- a/ChangeLog	Tue Aug 25 20:15:04 2015 +0200
+++ b/ChangeLog	Tue Aug 25 20:25:30 2015 +0200
@@ -15,6 +15,8 @@
 	* tune/tuneup.c (tune_mullo): Set MULLO_MUL_N_THRESHOLD to never
 	whenever the FFT threshold does not exist.
 
+	* mpf/cmp.c: Remove some branches.
+
 2015-08-25  Torbjörn Granlund  <torbjorng at google.com>
 
 	* mpn/x86_64/x86_64-defs.m4: Output computed numbers in base-10 instead
diff -r 7121e1053956 -r 96c2d3d6be92 mpf/cmp.c
--- a/mpf/cmp.c	Tue Aug 25 20:15:04 2015 +0200
+++ b/mpf/cmp.c	Tue Aug 25 20:25:30 2015 +0200
@@ -1,6 +1,6 @@
 /* mpf_cmp -- Compare two floats.
 
-Copyright 1993, 1994, 1996, 2001 Free Software Foundation, Inc.
+Copyright 1993, 1994, 1996, 2001, 2015 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -40,11 +40,9 @@
   int cmp;
   int usign;
 
-  uexp = u->_mp_exp;
-  vexp = v->_mp_exp;
-
-  usize = u->_mp_size;
-  vsize = v->_mp_size;
+  usize = SIZ(u);
+  vsize = SIZ(v);
+  usign = usize >= 0 ? 1 : -1;
 
   /* 1. Are the signs different?  */
   if ((usize ^ vsize) >= 0)
@@ -61,12 +59,13 @@
   else
     {
       /* Either U or V is negative, but not both.  */
-      return usize >= 0 ? 1 : -1;
+      return usign;
     }
 
   /* U and V have the same sign and are both non-zero.  */
 
-  usign = usize >= 0 ? 1 : -1;
+  uexp = EXP(u);
+  vexp = EXP(v);
 
   /* 2. Are the exponents different?  */
   if (uexp > vexp)
@@ -77,35 +76,33 @@
   usize = ABS (usize);
   vsize = ABS (vsize);
 
-  up = u->_mp_d;
-  vp = v->_mp_d;
+  up = PTR (u);
+  vp = PTR (v);
 
 #define STRICT_MPF_NORMALIZATION 0
 #if ! STRICT_MPF_NORMALIZATION
   /* Ignore zeroes at the low end of U and V.  */
-  while (up[0] == 0)
-    {
-      up++;
-      usize--;
-    }
-  while (vp[0] == 0)
-    {
-      vp++;
-      vsize--;
-    }
+  do {
+    mp_limb_t tl;
+    tl = up[0];
+    MPN_STRIP_LOW_ZEROS_NOT_ZERO (up, usize, tl);
+    tl = vp[0];
+    MPN_STRIP_LOW_ZEROS_NOT_ZERO (vp, vsize, tl);
+  } while (0);
 #endif
 
   if (usize > vsize)
     {
       cmp = mpn_cmp (up + usize - vsize, vp, vsize);
-      if (cmp == 0)
-	return usign;
+      /* if (cmp == 0) */
+      /* 	return usign; */
+      ++cmp; 
     }
   else if (vsize > usize)
     {
       cmp = mpn_cmp (up, vp + vsize - usize, usize);
-      if (cmp == 0)
-	return -usign;
+      /* if (cmp == 0) */
+      /* 	return -usign; */
     }
   else
     {


More information about the gmp-commit mailing list