[Gmp-commit] /var/hg/gmp: Fix canonicalization condition in binary mpn_gcdext_1.

mercurial at gmplib.org mercurial at gmplib.org
Tue Oct 1 15:43:12 UTC 2019


details:   /var/hg/gmp/rev/a1ec48261718
changeset: 17930:a1ec48261718
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Tue Oct 01 17:42:25 2019 +0200
description:
Fix canonicalization condition in binary mpn_gcdext_1.

diffstat:

 ChangeLog              |  5 +++++
 mpn/generic/gcdext_1.c |  7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r 397b0a8e50de -r a1ec48261718 ChangeLog
--- a/ChangeLog	Mon Sep 30 23:05:52 2019 +0200
+++ b/ChangeLog	Tue Oct 01 17:42:25 2019 +0200
@@ -1,3 +1,8 @@
+2019-10-01  Niels Möller  <nisse at lysator.liu.se>
+
+	* mpn/generic/gcdext_1.c (mpn_gcdext_1) [GCDEXT_1_USE_BINARY]: Fix
+	canonicalization condition.
+
 2019-09-30  Niels Möller  <nisse at lysator.liu.se>
 
 	* tests/mpn/t-gcdext_1.c: New test.
diff -r 397b0a8e50de -r a1ec48261718 mpn/generic/gcdext_1.c
--- a/mpn/generic/gcdext_1.c	Mon Sep 30 23:05:52 2019 +0200
+++ b/mpn/generic/gcdext_1.c	Tue Oct 01 17:42:25 2019 +0200
@@ -248,8 +248,11 @@
       s0 += mask & vgh;
       t0 += mask & ugh;
     }
-  /* FIXME: Try simplifying this condition. */
-  if ( (s0 > 1 && 2*s0 >= vg) || (t0 > 1 && 2*t0 >= ug) )
+
+  ASSERT_ALWAYS (s0 <= vg);
+  ASSERT_ALWAYS (t0 <= ug);
+
+  if (s0 > vg - s0)
     {
       s0 -= vg;
       t0 -= ug;


More information about the gmp-commit mailing list