[Gmp-commit] /var/hg/gmp: mpn/generic/sqrlo_basecase.c: reorder variable decl...
mercurial at gmplib.org
mercurial at gmplib.org
Wed Aug 12 06:16:59 UTC 2015
details: /var/hg/gmp/rev/41f8b5ca01d1
changeset: 16765:41f8b5ca01d1
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Wed Aug 12 08:16:53 2015 +0200
description:
mpn/generic/sqrlo_basecase.c: reorder variable declarations.
diffstat:
mpn/generic/sqrlo_basecase.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diffs (55 lines):
diff -r 2190398bf42a -r 41f8b5ca01d1 mpn/generic/sqrlo_basecase.c
--- a/mpn/generic/sqrlo_basecase.c Fri Aug 07 00:26:02 2015 +0200
+++ b/mpn/generic/sqrlo_basecase.c Wed Aug 12 08:16:53 2015 +0200
@@ -95,15 +95,15 @@
void
mpn_sqrlo_basecase (mp_ptr rp, mp_srcptr up, mp_size_t n)
{
- mp_size_t i;
+ mp_limb_t ul;
ASSERT (n >= 1);
ASSERT (! MPN_OVERLAP_P (rp, n, up, n));
+ ul = up[0];
+
if (n <= SQRLO_SPECIAL_CASES)
{
- mp_limb_t ul;
- ul = up[0];
#if SQRLO_SPECIAL_CASES == 1
rp[0] = (ul * ul) & GMP_NUMB_MASK;
#else
@@ -144,22 +144,26 @@
else
{
mp_limb_t tp[2 * SQR_TOOM2_THRESHOLD - 1];
+ mp_size_t i;
/* must fit n-1 limbs in tp */
ASSERT (n <= 2 * SQR_TOOM2_THRESHOLD);
--n;
-#ifdef SHORTCUT_MULTIPLICATIONS
+#ifdef SQRLO_SHORTCUT_MULTIPLICATIONS
{
mp_limb_t cy;
-
- cy = mpn_mul_1 (tp, up + 1, n - 1, up[0]) + up[0] * up[n];
+
+ cy = mpn_mul_1 (tp, up + 1, n - 1, ul) + ul * up[n];
for (i = 1; 2 * i + 1 < n; ++i)
- cy += mpn_addmul_1 (tp + 2 * i, up + i + 1, n - 2 * i - 1, up[i]) + up[i] * up[n - i];
- tp [n-1] = (cy + ((n & 1)?up[i] * up[n - i]:0)) & GMP_NUMB_MASK;
+ {
+ ul = up[i];
+ cy += mpn_addmul_1 (tp + 2 * i, up + i + 1, n - 2 * i - 1, ul) + ul * up[n - i];
+ }
+ tp [n-1] = (cy + ((n & 1)?up[i] * up[i + 1]:0)) & GMP_NUMB_MASK;
}
#else
- mpn_mul_1 (tp, up + 1, n, up[0]);
+ mpn_mul_1 (tp, up + 1, n, ul);
for (i = 1; 2 * i < n; ++i)
mpn_addmul_1 (tp + 2 * i, up + i + 1, n - 2 * i, up[i]);
#endif
More information about the gmp-commit
mailing list