Commit 0becaad3 authored by Armin Rigo's avatar Armin Rigo
Browse files

Revert 18443d3a74d5: the branch int-test-is-zero is maybe a nice idea

but it doesn't really work.  E.g. when we write "if a & 3:" at app-level
then the value "a & 3" is anyway passed around as failargs.  So this
branch makes the CPU compute twice this value, basically.

This is an almost-complete-revert: I'm keeping the new TEST_xx instructions in
rx86.py because the next time they're needed we'll already have them.
parent 9f75a49ee933
import py, sys
import platform
from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
......@@ -421,23 +420,3 @@ class TestMisc(BaseTestPyPyC):
# the following assertion fails if the loop was cancelled due
# to "abort: vable escape"
assert len(loops) == 1
def test_bit_check(self):
if not platform.machine().startswith('x86'):
py.test.skip("only x86 supports int_test_instructions for now")
def main(n):
x = 0
while n:
y = bool(n & 7) # ID: bitcheck
x += y
n -= 1
log = self.run(main, [300])
loop, = log.loops_by_id("bitcheck")
assert loop.match_by_id("bitcheck", """
guard_not_invalidated?
i11 = int_and(i7, 7) # not used
i12 = int_test_is_true(i7, 7)
guard_true(i12, descr=...)
""")
......@@ -333,7 +333,6 @@ class LLGraphCPU(model.AbstractCPU):
vector_ext.enable(16, accum=True)
vector_ext.setup_once = lambda asm: asm
load_supported_factors = (1,2,4,8)
supports_int_test_instructions = True
assembler = None
def __init__(self, rtyper, stats=None, *ignored_args, **kwds):
......
......@@ -20,7 +20,6 @@ class AbstractCPU(object):
supports_singlefloats = False
supports_guard_gc_type = False
supports_load_effective_address = False
supports_int_test_instructions = False
propagate_exception_descr = None
......
......@@ -1491,8 +1491,6 @@ class BaseBackendTest(Runner):
(rop.INT_NE, lambda x, y: x != y),
(rop.INT_GT, lambda x, y: x > y),
(rop.INT_GE, lambda x, y: x >= y),
(rop.INT_TEST_IS_ZERO, lambda x, y: (x & y) == 0),
(rop.INT_TEST_IS_TRUE, lambda x, y: (x & y) != 0),
]:
for opguard, guard_case in [
(rop.GUARD_FALSE, False),
......
......@@ -546,8 +546,6 @@ for _op in [rop.INT_LT,
rop.UINT_LE,
rop.UINT_GT,
rop.UINT_GE,
rop.INT_TEST_IS_ZERO,
rop.INT_TEST_IS_TRUE,
]:
OPERATIONS.append(BinaryOperation(_op, boolres=True))
......
......@@ -1281,17 +1281,6 @@ class Assembler386(BaseAssembler, VectorAssemblerMixin):
self.flush_cc(cond, result_loc)
return genop_cmp
def _testop(cond):
cond = rx86.Conditions[cond]
#
def genop_test(self, op, arglocs, result_loc):
if arglocs[1].is_stack() or isinstance(arglocs[0], ImmedLoc):
self.mc.TEST(arglocs[1], arglocs[0])
else:
self.mc.TEST(arglocs[0], arglocs[1])
self.flush_cc(cond, result_loc)
return genop_test
def _if_parity_clear_zero_and_carry(self):
jnp_location = self.mc.emit_forward_jump('NP')
# CMP EBP, 0: as EBP cannot be null here, that operation should
......@@ -1412,9 +1401,6 @@ class Assembler386(BaseAssembler, VectorAssemblerMixin):
genop_float_gt = _cmpop_float("A", "B")
genop_float_ge = _cmpop_float("AE","BE")
genop_int_test_is_zero = _testop("Z")
genop_int_test_is_true = _testop("NZ")
def genop_math_sqrt(self, op, arglocs, resloc):
self.mc.SQRTSD(arglocs[0], resloc)
......
......@@ -644,8 +644,6 @@ class RegAlloc(BaseRegalloc, VectorRegallocMixin):
consider_uint_ge = _consider_compop
consider_ptr_eq = consider_instance_ptr_eq = _consider_compop
consider_ptr_ne = consider_instance_ptr_ne = _consider_compop
consider_int_test_is_zero = _consider_compop
consider_int_test_is_true = _consider_compop
def _consider_float_op(self, op):
loc1 = self.xrm.loc(op.getarg(1))
......
......@@ -17,7 +17,6 @@ class AbstractX86CPU(AbstractLLCPU):
supports_floats = True
supports_singlefloats = True
supports_load_effective_address = True
supports_int_test_instructions = True
dont_keepalive_stuff = False # for tests
with_threads = False
......
......@@ -542,12 +542,6 @@ class BlackholeInterpreter(object):
@arguments("i", "i", returns="i")
def bhimpl_int_signext(a, b):
return int_signext(a, b)
@arguments("i", "i", returns="i")
def bhimpl_int_test_is_zero(a, b):
return (a & b) == 0
@arguments("i", "i", returns="i")
def bhimpl_int_test_is_true(a, b):
return (a & b) != 0
@arguments("i", "i", returns="i")
def bhimpl_uint_lt(a, b):
......
......@@ -442,8 +442,6 @@ def _make_execute_list():
rop.GC_STORE_INDEXED,
rop.LOAD_FROM_GC_TABLE,
rop.LOAD_EFFECTIVE_ADDRESS,
rop.INT_TEST_IS_ZERO,
rop.INT_TEST_IS_TRUE,
): # list of opcodes never executed by pyjitpl
continue
if rop._VEC_PURE_FIRST <= value <= rop._VEC_PURE_LAST:
......
......@@ -646,16 +646,6 @@ class OptRewrite(Optimization):
elif info == INFO_NULL:
self.make_constant_int(op, not expect_nonnull)
else:
if self.optimizer.cpu.supports_int_test_instructions:
box = get_box_replacement(box)
box1 = self.optimizer.as_operation(box)
if box1 is not None and box1.getopnum() == rop.INT_AND:
if expect_nonnull:
opnum = rop.INT_TEST_IS_TRUE
else:
opnum = rop.INT_TEST_IS_ZERO
args = [box1.getarg(0), box1.getarg(1)]
op = self.replace_op_with(op, opnum, args=args)
return self.emit(op)
def optimize_INT_IS_TRUE(self, op):
......
......@@ -5790,33 +5790,3 @@ class TestOptimizeBasic(BaseTestBasic):
i57 = int_or(i51, i52)
"""
self.optimize_loop(ops, expected)
def test_int_test_is_zero(self):
ops = """
[i1, i2]
i51 = int_and(i1, i2)
i52 = int_is_zero(i51)
guard_true(i52) []
"""
expected = """
[i1, i2]
i51 = int_and(i1, i2) # likely dead instruction
i52 = int_test_is_zero(i1, i2)
guard_true(i52) []
"""
self.optimize_loop(ops, expected)
def test_int_test_is_true(self):
ops = """
[i1, i2]
i51 = int_and(i1, i2)
i52 = int_is_true(i51)
guard_true(i52) []
"""
expected = """
[i1, i2]
i51 = int_and(i1, i2) # likely dead instruction
i52 = int_test_is_true(i1, i2)
guard_true(i52) []
"""
self.optimize_loop(ops, expected)
......@@ -1036,8 +1036,6 @@ _oplist = [
'INT_NEG/1/i',
'INT_INVERT/1/i',
'INT_FORCE_GE_ZERO/1/i',
'INT_TEST_IS_ZERO/2b/i',
'INT_TEST_IS_TRUE/2b/i',
#
'SAME_AS/1/ifr', # gets a Const or a Box, turns it into another Box
'CAST_PTR_TO_INT/1/i',
......
......@@ -4832,11 +4832,3 @@ class TestLLtype(BaseLLtypeTests, LLJitMixin):
res2 = self.interp_operations(f, [6])
assert res1 == res2
self.check_operations_history(guard_class=1, record_exact_class=0)
def test_int_test_instructions(self):
def f(x, y):
if (x & 7) == 0 and (y & 7) != 0:
return 1
return 0
res = self.interp_operations(f, [24, 25])
assert res == 1
......@@ -187,8 +187,6 @@ def _int_comparison_operations():
(rop.UINT_LE, lambda x, y: r_uint(x) <= r_uint(y)),
(rop.UINT_GT, lambda x, y: r_uint(x) > r_uint(y)),
(rop.UINT_GE, lambda x, y: r_uint(x) >= r_uint(y)),
(rop.INT_TEST_IS_ZERO, lambda x, y: (x & y) == 0),
(rop.INT_TEST_IS_TRUE, lambda x, y: (x & y) != 0),
]:
for i in range(20):
x = pick()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment