diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2019-06-07 12:42:41 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2019-06-07 12:42:41 +0000 |
commit | 4ef5ecef99c2067c38f33ec1f51a58dc682e7153 (patch) | |
tree | 987ac86baa302f913e43c9e9af5ad63cdd831b78 /src/sub1sp.c | |
parent | 4d0fbb66d892cbbcc8989c8dd4a7ce7a440b3fd5 (diff) | |
download | mpfr-4ef5ecef99c2067c38f33ec1f51a58dc682e7153.tar.gz |
[src/sub1sp.c] simplified code of sub1sp1 for bx = cx
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13511 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/sub1sp.c')
-rw-r--r-- | src/sub1sp.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/src/sub1sp.c b/src/sub1sp.c index 51bd33b83..a8c39a266 100644 --- a/src/sub1sp.c +++ b/src/sub1sp.c @@ -120,13 +120,7 @@ mpfr_sub1sp1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode, if (bx == cx) { - MPFR_ASSERTD (bp[0] >= MPFR_LIMB_HIGHBIT); - MPFR_ASSERTD (cp[0] >= MPFR_LIMB_HIGHBIT); - /* Thus, mathematically, the signed difference is between - 1 - MPFR_LIMB_HIGHBIT and MPFR_LIMB_HIGHBIT - 1, and the - most significant bit is equivalent to the usual sign bit. */ - a0 = bp[0] - cp[0]; - if (a0 == 0) /* result is zero */ + if (MPFR_UNLIKELY(bp[0] == cp[0])) /* result is zero */ { if (rnd_mode == MPFR_RNDD) MPFR_SET_NEG(a); @@ -135,21 +129,16 @@ mpfr_sub1sp1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode, MPFR_SET_ZERO(a); MPFR_RET (0); } - else if (a0 >= MPFR_LIMB_HIGHBIT) /* borrow: |c| > |b| */ + else if (cp[0] > bp[0]) /* borrow: |c| > |b| */ { - /* Note: The test before r13506 was a0 > bp[0], which should be - easier to optimize than a0 >= MPFR_LIMB_HIGHBIT on processors - with condition flags, i.e. the test should be a no-op as the - flag should have been obtained from the subtraction above. - See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30315>. - As of version 7, Clang knows to optimize the a0 > bp[0]. - TODO: revert the test in the future, once compilers have - improved? */ + a0 = cp[0] - bp[0]; MPFR_SET_OPPOSITE_SIGN (a, b); - a0 = -a0; } else /* bp[0] > cp[0] */ - MPFR_SET_SAME_SIGN (a, b); + { + a0 = bp[0] - cp[0]; + MPFR_SET_SAME_SIGN (a, b); + } /* now a0 != 0 */ MPFR_ASSERTD(a0 != 0); |