[Gmp-commit] /var/hg/gmp: New macro udiv_rnnd_preinv
mercurial at gmplib.org
mercurial at gmplib.org
Sun Feb 27 11:58:19 CET 2011
details: /var/hg/gmp/rev/7c2810e5f9d0
changeset: 13917:7c2810e5f9d0
user: Niels M?ller <nisse at lysator.liu.se>
date: Sun Feb 27 11:58:15 2011 +0100
description:
New macro udiv_rnnd_preinv
diffstat:
ChangeLog | 5 ++++-
gmp-impl.h | 24 ++++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletions(-)
diffs (53 lines):
diff -r 98add4b37ac1 -r 7c2810e5f9d0 ChangeLog
--- a/ChangeLog Sun Feb 27 00:29:38 2011 +0100
+++ b/ChangeLog Sun Feb 27 11:58:15 2011 +0100
@@ -1,3 +1,7 @@
+2011-02-27 Niels Möller <nisse at lysator.liu.se>
+
+ * gmp-impl.h (udiv_rnnd_preinv): New macro.
+
2011-02-27 Torbjorn Granlund <tege at gmplib.org>
* mpn/x86/atom/sse2/mul_basecase.asm: New file.
@@ -35,7 +39,6 @@
* mpn/x86/atom/copyd.asm: ReMoved (in mmx/ now).
* mpn/x86/atom/copyi.asm: Likewise.
* mpn/x86/atom/hamdist.asm: Likewise.
-
2011-02-24 Torbjorn Granlund <tege at gmplib.org>
diff -r 98add4b37ac1 -r 7c2810e5f9d0 gmp-impl.h
--- a/gmp-impl.h Sun Feb 27 00:29:38 2011 +0100
+++ b/gmp-impl.h Sun Feb 27 11:58:15 2011 +0100
@@ -2792,6 +2792,30 @@
(q) = _qh; \
} while (0)
+/* Unlike udiv_qrnnd_preinv, works also for nh == d.
+
+ FIXME: The special case for nl = constant 0 could be simplified
+ further, like in udiv_rnd_preinv below. Note that with nl = 0, the
+ case _r >= d can't happen. Also applies to udiv_qrnnd_preinv
+ above.
+
+ FIXME: Use mask for adjustment? */
+#define udiv_rnnd_preinv(r, nh, nl, d, di) \
+ do { \
+ mp_limb_t _qh, _ql, _r; \
+ umul_ppmm (_qh, _ql, (nh), (di)); \
+ if (__builtin_constant_p (nl) && (nl) == 0) \
+ _qh += (nh) + 1; \
+ else \
+ add_ssaaaa (_qh, _ql, _qh, _ql, (nh) + 1, (nl)); \
+ _r = (nl) - _qh * (d); \
+ if (_r > _ql) /* both > and >= should be OK */ \
+ _r += (d); \
+ if (UNLIKELY (_r >= (d))) \
+ _r -= (d); \
+ (r) = _r; \
+ } while (0)
+
/* Compute r = nh*B mod d, where di is the inverse of d. */
#define udiv_rnd_preinv(r, nh, d, di) \
do { \
More information about the gmp-commit
mailing list