[pypy-commit] pypy improve-rbigint: Only use rshift for power of two division if both are positive. This fixes the array tests
Stian Andreassen
noreply at buildbot.pypy.org
Mon Jul 23 02:30:36 CEST 2012
Author: Stian Andreassen
Branch: improve-rbigint
Changeset: r56396:6a80b272ad85
Date: 2012-07-23 02:30 +0200
http://bitbucket.org/pypy/pypy/changeset/6a80b272ad85/
Log: Only use rshift for power of two division if both are positive. This
fixes the array tests
diff --git a/pypy/rlib/rbigint.py b/pypy/rlib/rbigint.py
--- a/pypy/rlib/rbigint.py
+++ b/pypy/rlib/rbigint.py
@@ -465,10 +465,10 @@
@jit.elidable
def floordiv(self, other):
- if other.numdigits() == 1 and other.sign == 1:
+ if self.sign == 1 and other.numdigits() == 1 and other.sign == 1:
digit = other.digit(0)
if digit == 1:
- return rbigint(self._digits[:], other.sign * self.sign, self.size)
+ return rbigint(self._digits[:], 1, self.size)
elif digit and digit & (digit - 1) == 0:
return self.rshift(ptwotable[digit])
@@ -476,6 +476,7 @@
if mod.sign * other.sign == -1:
if div.sign == 0:
return ONENEGATIVERBIGINT
+
if div.sign == 1:
_v_isub(div, 0, div.numdigits(), ONERBIGINT, 1)
else:
@@ -854,7 +855,7 @@
if self.numdigits() == 1 and self._digits[0] == NULLDIGIT:
self.sign = 0
self._digits = [NULLDIGIT]
-
+
_normalize._always_inline_ = True
@jit.elidable
More information about the pypy-commit
mailing list