[pypy-svn] r37049 - in pypy/dist/pypy/jit/codegen: i386 test
arigo at codespeak.net
arigo at codespeak.net
Sat Jan 20 08:55:45 CET 2007
Author: arigo
Date: Sat Jan 20 08:55:42 2007
New Revision: 37049
Modified:
pypy/dist/pypy/jit/codegen/i386/rgenop.py
pypy/dist/pypy/jit/codegen/test/operation_tests.py
Log:
Fix unsigned division.
Modified: pypy/dist/pypy/jit/codegen/i386/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/rgenop.py (original)
+++ pypy/dist/pypy/jit/codegen/i386/rgenop.py Sat Jan 20 08:55:42 2007
@@ -224,7 +224,10 @@
if op1 != eax:
mc.MOV(eax, op1)
if self.input_is_64bits:
- mc.CDQ()
+ if self.unsigned:
+ mc.XOR(edx, edx)
+ else:
+ mc.CDQ()
try:
self.emit(mc, op2)
except FailedToImplement:
@@ -295,6 +298,7 @@
opname = 'int_mod'
input_is_64bits = True
reg_containing_result = edx
+ unsigned = False
@staticmethod
def emit(mc, op2):
# Python i386
@@ -334,18 +338,21 @@
opname = 'uint_mul'
input_is_64bits = False
reg_containing_result = eax
+ unsigned = True
emit = staticmethod(I386CodeBuilder.MUL)
class OpUIntFloorDiv(MulOrDivOp):
opname = 'uint_floordiv'
input_is_64bits = True
reg_containing_result = eax
+ unsigned = True
emit = staticmethod(I386CodeBuilder.DIV)
class OpUIntMod(MulOrDivOp):
opname = 'uint_mod'
input_is_64bits = True
reg_containing_result = edx
+ unsigned = True
emit = staticmethod(I386CodeBuilder.DIV)
class OpIntLShift(Op2):
Modified: pypy/dist/pypy/jit/codegen/test/operation_tests.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/test/operation_tests.py (original)
+++ pypy/dist/pypy/jit/codegen/test/operation_tests.py Sat Jan 20 08:55:42 2007
@@ -226,6 +226,11 @@
assert fp1(149, 33) == fn1(149, 33)
assert fp1(149, 65) == fn1(149, 65)
assert fp1(149, 150) == fn1(149, 150)
+ big = r_uint(-42)
+ assert fp1(big, 3) == fn1(big, 3)
+ if op not in ('x << y', 'x >> y'):
+ assert fp1(38, big) == fn1(38, big)
+ assert fp1(big-5, big-12) == fn1(big-5, big-12)
def test_float_arithmetic(self):
for op, fn in [('x + y', lambda x, y: x + y),
More information about the Pypy-commit
mailing list