[Gmp-commit] /var/hg/gmp: Simplified normalized case for mpn_sec_div_qr and m...
mercurial at gmplib.org
mercurial at gmplib.org
Sat Feb 8 16:15:17 UTC 2014
details: /var/hg/gmp/rev/4d73e11088f0
changeset: 16282:4d73e11088f0
user: Niels M?ller <nisse at lysator.liu.se>
date: Sat Feb 08 17:15:10 2014 +0100
description:
Simplified normalized case for mpn_sec_div_qr and mpn_sec_div_r.
diffstat:
ChangeLog | 2 ++
mpn/generic/sec_div.c | 25 ++++++++++---------------
2 files changed, 12 insertions(+), 15 deletions(-)
diffs (74 lines):
diff -r fb57e139c53a -r 4d73e11088f0 ChangeLog
--- a/ChangeLog Sat Feb 08 16:52:59 2014 +0100
+++ b/ChangeLog Sat Feb 08 17:15:10 2014 +0100
@@ -1,5 +1,7 @@
2014-02-08 Niels Möller <nisse at lysator.liu.se>
+ * mpn/generic/sec_div.c: Simplified code for the normalized case.
+
* tests/mpn/t-div.c (main): Test mpn_sec_div_qr and mpn_sec_div_r
with normalized d.
diff -r fb57e139c53a -r 4d73e11088f0 mpn/generic/sec_div.c
--- a/mpn/generic/sec_div.c Sat Feb 08 16:52:59 2014 +0100
+++ b/mpn/generic/sec_div.c Sat Feb 08 17:15:10 2014 +0100
@@ -71,12 +71,10 @@
mp_srcptr dp, mp_size_t dn,
mp_ptr tp)
{
- mp_limb_t d1, d0, qh;
+ mp_limb_t d1, d0;
unsigned int cnt;
- mp_ptr np2, dp2;
gmp_pi1_t dinv;
mp_limb_t inv32;
- mp_limb_t cy;
ASSERT (dn >= 1);
ASSERT (nn >= dn);
@@ -87,6 +85,8 @@
if (cnt != 0)
{
+ mp_limb_t qh, cy;
+ mp_ptr np2, dp2;
dp2 = tp; /* dn limbs */
mpn_lshift (dp2, dp, dn, cnt);
@@ -110,29 +110,24 @@
#endif
mpn_rshift (np, np2, dn, cnt);
+
+#if OPERATION_sec_div_qr
+ return qh;
+#endif
}
else
{
/* FIXME: Consider copying np => np2 here, adding a 0-limb at the top.
That would simplify the underlying pi1 function, since then it could
assume nn > dn. */
- dp2 = (mp_ptr) dp;
- np2 = np;
-
- d0 = dp2[dn - 1];
+ d0 = dp[dn - 1];
d0 += (~d0 != 0);
invert_limb (inv32, d0);
- /* We add nn + dn to tp here, not nn + 1 + dn, as expected. This is
- since nn here will have been incremented. */
#if OPERATION_sec_div_qr
- qh = mpn_sec_pi1_div_qr (qp, np2, nn, dp2, dn, inv32, tp + nn + dn);
+ return mpn_sec_pi1_div_qr (qp, np, nn, dp, dn, inv32, tp);
#else
- mpn_sec_pi1_div_r (np2, nn, dp2, dn, inv32, tp + nn + dn);
+ mpn_sec_pi1_div_r (np, nn, dp, dn, inv32, tp);
#endif
}
-
-#if OPERATION_sec_div_qr
- return qh;
-#endif
}
More information about the gmp-commit
mailing list