summaryrefslogtreecommitdiff
path: root/src/add1sp.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2017-01-13 10:44:44 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2017-01-13 10:44:44 +0000
commit17972f0785fd307dc98d184b1e5dc8f21a6c6459 (patch)
tree835abf5f5ad5d1ac5f2cf67891f77116c705d02e /src/add1sp.c
parent65de9d483c7affdfd05190732ee812aea4de75b3 (diff)
downloadmpfr-17972f0785fd307dc98d184b1e5dc8f21a6c6459.tar.gz
[src/add1sp.c] Improvements in mpfr_add1sp1; added a TODO.
Note for rb -> bp[0]: the generated code is the same, but the source is more readable (-> rb has only one meaning). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11196 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/add1sp.c')
-rw-r--r--src/add1sp.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/add1sp.c b/src/add1sp.c
index 405e56347..6f2021f48 100644
--- a/src/add1sp.c
+++ b/src/add1sp.c
@@ -134,14 +134,17 @@ mpfr_add1sp1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode,
BGreater1:
d = (mpfr_uexp_t) bx - cx;
mask = MPFR_LIMB_MASK(sh);
+ /* TODO: Should the case d < sh be removed, i.e. seen as a particular
+ case of d < GMP_NUMB_BITS? This case would do a bit more operations
+ but a test would be removed, avoiding pipeline stall issues. */
if (d < sh)
{
/* we can shift c by d bits to the right without losing any bit,
moreover we can shift one more if there is an exponent increase */
- rb = bp[0];
- a0 = rb + (cp[0] >> d);
- if (a0 < rb) /* carry */
+ a0 = bp[0] + (cp[0] >> d);
+ if (a0 < bp[0]) /* carry */
{
+ MPFR_ASSERTD ((a0 & 1) == 0);
a0 = MPFR_LIMB_HIGHBIT | (a0 >> 1);
bx ++;
}
@@ -151,10 +154,9 @@ mpfr_add1sp1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode,
}
else if (d < GMP_NUMB_BITS) /* sh <= d < GMP_NUMB_BITS */
{
- rb = bp[0];
sb = cp[0] << (GMP_NUMB_BITS - d); /* bits from cp[-1] after shift */
- a0 = rb + (cp[0] >> d);
- if (a0 < rb)
+ a0 = bp[0] + (cp[0] >> d);
+ if (a0 < bp[0]) /* carry */
{
sb |= a0 & 1;
a0 = MPFR_LIMB_HIGHBIT | (a0 >> 1);
@@ -180,9 +182,9 @@ mpfr_add1sp1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode,
goto BGreater1;
}
- /* Note: we could keep the output significand in a0 for the rounding, and only
- store it in ap[0] at the very end, but this seems slower on average (but better
- for the worst case). */
+ /* Note: we could keep the output significand in a0 for the rounding,
+ and only store it in ap[0] at the very end, but this seems slower
+ on average (but better for the worst case). */
/* now perform rounding */
if (MPFR_UNLIKELY(bx > __gmpfr_emax))