summaryrefslogtreecommitdiff
path: root/src/sub1sp.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-08-27 15:03:05 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-08-27 15:03:05 +0000
commit0bab294f3f1cf0f42f49d659a49659df0c078373 (patch)
tree5613daf6bc9d515111e366111359138c7aec0532 /src/sub1sp.c
parentda96cfa4d99c8bdb08aceb6c17267405d8f403e6 (diff)
downloadmpfr-0bab294f3f1cf0f42f49d659a49659df0c078373.tar.gz
[src/sub1sp.c] Avoid bad usage of tp in the generic code:
* In the case d == 1, two branches were inconsistent: tp not defined at the same level, with one shadowing the other one. * In the case 2 <= d < p, tp was reused with a different meanings; renamed the second one to cp, as this is MPFR_MANT(c). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13043 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/sub1sp.c')
-rw-r--r--src/sub1sp.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/sub1sp.c b/src/sub1sp.c
index 30580db4b..7cd94c577 100644
--- a/src/sub1sp.c
+++ b/src/sub1sp.c
@@ -1292,7 +1292,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
{
/* | <-- b -->
| <-- c --> */
- mp_limb_t c0, mask, *tp;
+ mp_limb_t c0, mask;
MPFR_UNSIGNED_MINUS_MODULO(sh, p);
/* If we lose at least one bit, compute 2*b-c (Exact)
* else compute b-c/2 */
@@ -1307,6 +1307,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
below necessarily yield a > 1/2*W^n. */
if (limb > MPFR_LIMB_HIGHBIT) /* case limb > W/2 */
{
+ mp_limb_t *tp;
/* The exponent cannot decrease: compute b-c/2 */
/* Shift c in the allocated temporary block */
SubD1NoLose:
@@ -1499,15 +1500,15 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
/* Compute rb=Cp and sb=C'p+1 */
{
/* Compute rb and rbb from C */
- tp = MPFR_MANT(c);
+ mp_limb_t *cp = MPFR_MANT(c);
/* The round bit is bit p-d in C, assuming the most significant bit
of C is bit 0 */
mpfr_prec_t x = p - d;
mp_size_t kx = n - 1 - (x / GMP_NUMB_BITS);
mpfr_prec_t sx = GMP_NUMB_BITS - 1 - (x % GMP_NUMB_BITS);
- /* the round bit is in tp[kx], at position sx */
+ /* the round bit is in cp[kx], at position sx */
MPFR_ASSERTD(p >= d);
- rb = tp[kx] & (MPFR_LIMB_ONE << sx);
+ rb = cp[kx] & (MPFR_LIMB_ONE << sx);
/* Now compute rbb: since d >= 2 it always exists in C */
if (sx == 0) /* rbb is in the next limb */
@@ -1517,12 +1518,12 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
}
else
sx --; /* rb and rbb are in the same limb */
- rbb = tp[kx] & (MPFR_LIMB_ONE << sx);
+ rbb = cp[kx] & (MPFR_LIMB_ONE << sx);
/* Now look at the remaining low bits of C to determine sbb */
- sbb = tp[kx] & MPFR_LIMB_MASK(sx);
+ sbb = cp[kx] & MPFR_LIMB_MASK(sx);
while (sbb == 0 && kx > 0)
- sbb = tp[--kx];
+ sbb = cp[--kx];
}
/* printf("sh=%lu Cp=%d C'p+1=%d\n", sh, rb!=0, sb!=0); */