summaryrefslogtreecommitdiff
path: root/sub1.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2003-11-25 17:22:31 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2003-11-25 17:22:31 +0000
commit82f2604d99ad36b65e4342e03c05a02ee77f1068 (patch)
treea7a9abb5ce0e6c0b2815d9c1e57f57aa8c2eec1f /sub1.c
parent83c4428fadeab214993b680317a727cb1e2a50a1 (diff)
downloadmpfr-82f2604d99ad36b65e4342e03c05a02ee77f1068.tar.gz
Optmize a few add1.c/sub1.c by using MPFR_LIKELY / MPFR_UNLIKELY.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2564 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'sub1.c')
-rw-r--r--sub1.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sub1.c b/sub1.c
index c12baefd5..00c670466 100644
--- a/sub1.c
+++ b/sub1.c
@@ -392,13 +392,14 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
inexact = 0;
goto truncate;
- sub_one_ulp: /* add one unit in last place to a */
+ sub_one_ulp: /* sub one unit in last place to a */
mpn_sub_1 (ap, ap, an, MP_LIMB_T_ONE << sh);
inexact = -1;
goto end_of_sub;
add_one_ulp: /* add one unit in last place to a */
- if (mpn_add_1 (ap, ap, an, MP_LIMB_T_ONE << sh)) /* result is a power of 2 */
+ if (MPFR_UNLIKELY(mpn_add_1 (ap, ap, an, MP_LIMB_T_ONE << sh)))
+ /* result is a power of 2: 11111111111111 + 1 = 1000000000000000 */
{
ap[an-1] = MPFR_LIMB_HIGHBIT;
add_exp = 1;
@@ -406,7 +407,8 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
inexact = 1; /* result larger than exact value */
truncate:
- if ((ap[an-1] >> (BITS_PER_MP_LIMB - 1)) == 0) /* case 1 - epsilon */
+ if (MPFR_UNLIKELY((ap[an-1] >> (BITS_PER_MP_LIMB - 1)) == 0))
+ /* case 1 - epsilon */
{
ap[an-1] = MPFR_LIMB_HIGHBIT;
add_exp = 1;