[pypy-svn] r37398 - in pypy/dist/pypy/jit/codegen: i386 test
arigo at codespeak.net
arigo at codespeak.net
Fri Jan 26 17:46:15 CET 2007
Author: arigo
Date: Fri Jan 26 17:46:14 2007
New Revision: 37398
Modified:
pypy/dist/pypy/jit/codegen/i386/operation.py
pypy/dist/pypy/jit/codegen/test/operation_tests.py
Log:
More bugs, more fixes...
Modified: pypy/dist/pypy/jit/codegen/i386/operation.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/operation.py (original)
+++ pypy/dist/pypy/jit/codegen/i386/operation.py Fri Jan 26 17:46:14 2007
@@ -291,10 +291,10 @@
mc.SUB(eax, ecx)
mc.SBB(edx, imm8(0))
else:
- # if op1 is positive (or null), add (op2-1)
+ # if op1 is positive (or null), add (|op2|-1)
mc.MOV(ecx, edx)
- mc.NEG(ecx) # -1 if op1 is positive, 0 otherwise
- mc.AND(ecx, imm(op2.value-1))
+ mc.NOT(ecx) # -1 if op1 is positive, 0 otherwise
+ mc.AND(ecx, imm(-op2.value-1))
mc.ADD(eax, ecx)
mc.ADC(edx, imm8(0))
mc.MOV(ecx, op2)
@@ -326,19 +326,15 @@
if isinstance(op2, IMM32):
mc.MOV(ecx, op2)
mc.IDIV(ecx)
- if op2.value >= 0:
- # if the result is negative, add op2 to it
- mc.MOV(ecx, edx)
- mc.SAR(ecx, imm8(31))
- mc.AND(ecx, imm(op2.value))
- mc.ADD(edx, ecx)
- else:
- # if the result is > 0, subtract op2 from it
- mc.MOV(ecx, edx)
+ # adjustment needed:
+ # if op2 > 0: if the result is negative, add op2 to it
+ # if op2 < 0: if the result is > 0, subtract |op2| from it
+ mc.MOV(ecx, edx)
+ if op2.value < 0:
mc.NEG(ecx)
- mc.SAR(ecx, imm8(31))
- mc.AND(ecx, imm(op2.value))
- mc.SUB(edx, ecx)
+ mc.SAR(ecx, imm8(31))
+ mc.AND(ecx, imm(op2.value))
+ mc.ADD(edx, ecx)
else:
# if the operand signs differ and the remainder is not zero,
# add operand2 to the result
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 Fri Jan 26 17:46:14 2007
@@ -290,7 +290,7 @@
def test_constants_in_divmod(self):
for op in ['x // y', 'x % y']:
- for constant in range(1, 20):
+ for constant in range(1, 20) + range(-1, -20, -1):
fn = eval("lambda x: " + op, {'y': constant})
fp = self.rgen(fn, [int], int)
for operand1 in range(-32, 33):
More information about the Pypy-commit
mailing list