[Gmp-commit] /home/hgfiles/gmp: Rework temp allocation.

mercurial at gmplib.org mercurial at gmplib.org
Tue Dec 1 21:17:42 CET 2009


details:   /home/hgfiles/gmp/rev/68caff9d2bf8
changeset: 12955:68caff9d2bf8
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Tue Dec 01 21:17:22 2009 +0100
description:
Rework temp allocation.

diffstat:

 ChangeLog            |   2 ++
 mpn/generic/redc_n.c |  20 ++++++++++----------
 2 files changed, 12 insertions(+), 10 deletions(-)

diffs (56 lines):

diff -r 5f53eb29eb3c -r 68caff9d2bf8 ChangeLog
--- a/ChangeLog	Tue Dec 01 20:16:29 2009 +0100
+++ b/ChangeLog	Tue Dec 01 21:17:22 2009 +0100
@@ -11,6 +11,8 @@
 
 2009-12-01  Torbjorn Granlund  <tege at gmplib.org>
 
+	* mpn/generic/redc_n.c: Rework temp allocation.
+
 	* mpn/generic/dcpi1_bdiv_qr.c (mpn_dcpi1_bdiv_qr_n_itch): Add pi1 also
 	to this function.
 
diff -r 5f53eb29eb3c -r 68caff9d2bf8 mpn/generic/redc_n.c
--- a/mpn/generic/redc_n.c	Tue Dec 01 20:16:29 2009 +0100
+++ b/mpn/generic/redc_n.c	Tue Dec 01 21:17:22 2009 +0100
@@ -41,30 +41,30 @@
 */
 
 void
-mpn_redc_n (mp_ptr rp, mp_ptr tp, mp_srcptr mp, mp_size_t n, mp_srcptr ip)
+mpn_redc_n (mp_ptr rp, mp_ptr up, mp_srcptr mp, mp_size_t n, mp_srcptr ip)
 {
-  mp_ptr xp, yp, scratch_out;
+  mp_ptr xp, yp, scratch;
   mp_limb_t cy;
   mp_size_t rn;
   TMP_DECL;
   TMP_MARK;
 
-  xp = TMP_ALLOC_LIMBS (3 * n);
-  yp = xp + n;
+  rn = mpn_mulmod_bnm1_next_size (n);
 
-  mpn_mullow_n (xp, tp, ip, n);
+  scratch = TMP_ALLOC_LIMBS (n + 3 * rn + 100);
 
-  rn = mpn_mulmod_bnm1_next_size (n);
-  scratch_out = TMP_ALLOC_LIMBS (2 * rn + 100);		/* FIXME */
+  xp = scratch;
+  mpn_mullow_n (xp, up, ip, n);
 
-  mpn_mulmod_bnm1 (yp, rn, xp, n, mp, n, scratch_out);
+  yp = scratch + n;
+  mpn_mulmod_bnm1 (yp, rn, xp, n, mp, n, scratch + n + rn);
 
   ASSERT_ALWAYS (2 * n > rn);				/* could handle this */
 
-  cy = mpn_sub_n (yp + rn, yp, tp, 2*n - rn);		/* undo wrap around */
+  cy = mpn_sub_n (yp + rn, yp, up, 2*n - rn);		/* undo wrap around */
   MPN_DECR_U (yp + 2*n - rn, rn, cy);
 
-  cy = mpn_sub_n (rp, tp + n, yp + n, n);
+  cy = mpn_sub_n (rp, up + n, yp + n, n);
   if (cy != 0)
     mpn_add_n (rp, rp, mp, n);
 


More information about the gmp-commit mailing list