[pypy-commit] pypy default: Revert 18443d3a74d5: the branch int-test-is-zero is maybe a nice idea
arigo
pypy.commits at gmail.com
Sun Nov 17 12:41:23 EST 2019
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r98098:37894e68890d
Date: 2019-11-17 18:40 +0100
http://bitbucket.org/pypy/pypy/changeset/37894e68890d/
Log: 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.
diff --git a/pypy/module/pypyjit/test_pypy_c/test_misc.py b/pypy/module/pypyjit/test_pypy_c/test_misc.py
--- a/pypy/module/pypyjit/test_pypy_c/test_misc.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_misc.py
@@ -1,5 +1,4 @@
import py, sys
-import platform
from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
@@ -421,23 +420,3 @@
# 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=...)
- """)
diff --git a/rpython/jit/backend/llgraph/runner.py b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -333,7 +333,6 @@
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):
diff --git a/rpython/jit/backend/model.py b/rpython/jit/backend/model.py
--- a/rpython/jit/backend/model.py
+++ b/rpython/jit/backend/model.py
@@ -20,7 +20,6 @@
supports_singlefloats = False
supports_guard_gc_type = False
supports_load_effective_address = False
- supports_int_test_instructions = False
propagate_exception_descr = None
diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py
--- a/rpython/jit/backend/test/runner_test.py
+++ b/rpython/jit/backend/test/runner_test.py
@@ -1491,8 +1491,6 @@
(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),
diff --git a/rpython/jit/backend/test/test_random.py b/rpython/jit/backend/test/test_random.py
--- a/rpython/jit/backend/test/test_random.py
+++ b/rpython/jit/backend/test/test_random.py
@@ -546,8 +546,6 @@
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))
diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -1281,17 +1281,6 @@
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 @@
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)
diff --git a/rpython/jit/backend/x86/regalloc.py b/rpython/jit/backend/x86/regalloc.py
--- a/rpython/jit/backend/x86/regalloc.py
+++ b/rpython/jit/backend/x86/regalloc.py
@@ -644,8 +644,6 @@
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))
diff --git a/rpython/jit/backend/x86/runner.py b/rpython/jit/backend/x86/runner.py
--- a/rpython/jit/backend/x86/runner.py
+++ b/rpython/jit/backend/x86/runner.py
@@ -17,7 +17,6 @@
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
diff --git a/rpython/jit/metainterp/blackhole.py b/rpython/jit/metainterp/blackhole.py
--- a/rpython/jit/metainterp/blackhole.py
+++ b/rpython/jit/metainterp/blackhole.py
@@ -542,12 +542,6 @@
@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):
diff --git a/rpython/jit/metainterp/executor.py b/rpython/jit/metainterp/executor.py
--- a/rpython/jit/metainterp/executor.py
+++ b/rpython/jit/metainterp/executor.py
@@ -442,8 +442,6 @@
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:
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -646,16 +646,6 @@
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):
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -5790,33 +5790,3 @@
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)
diff --git a/rpython/jit/metainterp/resoperation.py b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -1036,8 +1036,6 @@
'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',
diff --git a/rpython/jit/metainterp/test/test_ajit.py b/rpython/jit/metainterp/test/test_ajit.py
--- a/rpython/jit/metainterp/test/test_ajit.py
+++ b/rpython/jit/metainterp/test/test_ajit.py
@@ -4832,11 +4832,3 @@
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
diff --git a/rpython/jit/metainterp/test/test_executor.py b/rpython/jit/metainterp/test/test_executor.py
--- a/rpython/jit/metainterp/test/test_executor.py
+++ b/rpython/jit/metainterp/test/test_executor.py
@@ -187,8 +187,6 @@
(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()
More information about the pypy-commit
mailing list