summaryrefslogtreecommitdiff
path: root/src/sqr.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2017-02-11 15:26:07 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2017-02-11 15:26:07 +0000
commitafb28793807f6e98333096bb2ee3a4deb81720c8 (patch)
tree278f6d7fc47a4c0c999d7ae2e1fdde062aae6256 /src/sqr.c
parentb6d0f998077e0199748c7a42cac603764e1ce7af (diff)
downloadmpfr-afb28793807f6e98333096bb2ee3a4deb81720c8.tar.gz
[src/sqr.c] revert detection of leading bit in sqr_1 and sqr_2
(not clear it is faster) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11305 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/sqr.c')
-rw-r--r--src/sqr.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/sqr.c b/src/sqr.c
index d9591dcbe..7b4498d8d 100644
--- a/src/sqr.c
+++ b/src/sqr.c
@@ -45,16 +45,7 @@ mpfr_sqr_1 (mpfr_ptr a, mpfr_srcptr b, mpfr_rnd_t rnd_mode, mpfr_prec_t p)
*/
ax = MPFR_GET_EXP(b) * 2;
umul_ppmm (a0, sb, b0, b0);
- /* Instead of comparing a0 to MPFR_LIMB_HIGHBIT, we compare b0 to the
- smallest value giving a0 >= MPFR_LIMB_HIGHBIT. This should be more
- efficient since we don't have to wait the result of umul_ppmm to know
- which branch to take. */
-#if GMP_NUMB_BITS == 32
-#define MAGIC 3037000500UL /* ceil(sqrt(2^63)) */
-#else /* GMP_NUMB_BITS = 64 */
-#define MAGIC 13043817825332782213UL /* ceil(sqrt(2^127)) */
-#endif
- if (b0 < MAGIC) /* equivalent to a0 < MPFR_LIMB_HIGHBIT */
+ if (a0 < MPFR_LIMB_HIGHBIT)
{
ax --;
a0 = (a0 << 1) | (sb >> (GMP_NUMB_BITS - 1));
@@ -147,7 +138,7 @@ mpfr_sqr_1n (mpfr_ptr a, mpfr_srcptr b, mpfr_rnd_t rnd_mode)
ax = MPFR_GET_EXP(b) * 2;
umul_ppmm (a0, sb, b0, b0);
- if (b0 < MAGIC) /* equivalent to a0 < MPFR_LIMB_HIGHBIT */
+ if (a0 < MPFR_LIMB_HIGHBIT)
{
ax --;
a0 = (a0 << 1) | (sb >> (GMP_NUMB_BITS - 1));