[Gmp-commit] /var/hg/gmp: mpz/mul_i.h: Small clean-up.
mercurial at gmplib.org
mercurial at gmplib.org
Sat Apr 14 11:56:46 CEST 2012
details: /var/hg/gmp/rev/c2340eeb9a3c
changeset: 14820:c2340eeb9a3c
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sat Apr 14 11:56:42 2012 +0200
description:
mpz/mul_i.h: Small clean-up.
diffstat:
ChangeLog | 2 ++
mpz/mul_i.h | 22 +++++++++++-----------
2 files changed, 13 insertions(+), 11 deletions(-)
diffs (78 lines):
diff -r b18c0ee4f03f -r c2340eeb9a3c ChangeLog
--- a/ChangeLog Sat Apr 14 11:26:21 2012 +0200
+++ b/ChangeLog Sat Apr 14 11:56:42 2012 +0200
@@ -13,6 +13,8 @@
* tune/speed.h (SPEED_ROUTINE_MPN_MUPI_DIV_QR): Allocate scratch
space for mpn_invert.
+ * mpz/mul_i.h: Small clean-up.
+
2012-04-12 Torbjorn Granlund <tege at gmplib.org>
* mpn/x86_64/fastsse/lshift-movdqu2.asm: New file.
diff -r b18c0ee4f03f -r c2340eeb9a3c mpz/mul_i.h
--- a/mpz/mul_i.h Sat Apr 14 11:26:21 2012 +0200
+++ b/mpz/mul_i.h Sat Apr 14 11:56:42 2012 +0200
@@ -1,8 +1,8 @@
/* mpz_mul_ui/si (product, multiplier, small_multiplicand) -- Set PRODUCT to
MULTIPLICATOR times SMALL_MULTIPLICAND.
-Copyright 1991, 1993, 1994, 1996, 2000, 2001, 2002, 2005, 2008 Free Software
-Foundation, Inc.
+Copyright 1991, 1993, 1994, 1996, 2000, 2001, 2002, 2005, 2008, 2012
+Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -44,27 +44,27 @@
FUNCTION (mpz_ptr prod, mpz_srcptr mult,
MULTIPLICAND_UNSIGNED long int small_mult)
{
- mp_size_t size = SIZ(mult);
- mp_size_t sign_product = size;
+ mp_size_t size;
+ mp_size_t sign_product;
mp_limb_t sml;
mp_limb_t cy;
mp_ptr pp;
- if (size == 0 || small_mult == 0)
+ sign_product = SIZ(mult);
+ if (sign_product == 0 || small_mult == 0)
{
SIZ(prod) = 0;
return;
}
- size = ABS (size);
+ size = ABS (sign_product);
sml = MULTIPLICAND_ABS (small_mult);
if (sml <= GMP_NUMB_MAX)
{
- MPZ_REALLOC (prod, size + 1);
- pp = PTR(prod);
- cy = mpn_mul_1 (pp, PTR(mult), size, sml & GMP_NUMB_MASK);
+ pp = MPZ_REALLOC (prod, size + 1);
+ cy = mpn_mul_1 (pp, PTR(mult), size, sml);
pp[size] = cy;
size += cy != 0;
}
@@ -79,14 +79,14 @@
tp = TMP_ALLOC_LIMBS (size + 2);
+ /* Use, maybe, mpn_mul_2? */
cy = mpn_mul_1 (tp, PTR(mult), size, sml & GMP_NUMB_MASK);
tp[size] = cy;
cy = mpn_addmul_1 (tp + 1, PTR(mult), size, sml >> GMP_NUMB_BITS);
tp[size + 1] = cy;
size += 2;
MPN_NORMALIZE_NOT_ZERO (tp, size); /* too general, need to trim one or two limb */
- MPZ_REALLOC (prod, size);
- pp = PTR(prod);
+ pp = MPZ_REALLOC (prod, size);
MPN_COPY (pp, tp, size);
TMP_FREE;
}
More information about the gmp-commit
mailing list