diff options
author | Armin Rigo <arigo@tunes.org> | 2018-12-05 20:33:10 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2018-12-05 20:33:10 +0200 |
commit | 1880f466b3eab0f6a4a82c7ea3bd89ebba506e0c (patch) | |
tree | 985a95c3dadaa863f280410ccd4b01fa095b8903 | |
parent | Tentative fix for issue #2904 (diff) | |
download | pypy-1880f466b3eab0f6a4a82c7ea3bd89ebba506e0c.tar.gz pypy-1880f466b3eab0f6a4a82c7ea3bd89ebba506e0c.tar.bz2 pypy-1880f466b3eab0f6a4a82c7ea3bd89ebba506e0c.zip |
Re-enable this intbounds optimization. Found that tracking resops that are
*not* in the current loop is hard and error-prone; instead, track resops that
*are* in the current loop, and it's OK if we occasionally miss some.
5 files changed, 10 insertions, 13 deletions
diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py index 9857c6e2d0..a2c412d42e 100644 --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -128,7 +128,7 @@ class OptIntBounds(Optimization): # if both are constant, the pure optimization will deal with it if v2.is_constant() and not v1.is_constant(): arg1 = self.optimizer.as_operation(arg1) - if arg1 is not None and 0: # XXX check and re-enable this + if arg1 is not None: if arg1.getopnum() == rop.INT_ADD: prod_arg1 = arg1.getarg(0) prod_arg2 = arg1.getarg(1) diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py b/rpython/jit/metainterp/optimizeopt/optimizer.py index e39ed8521b..699226059b 100644 --- a/rpython/jit/metainterp/optimizeopt/optimizer.py +++ b/rpython/jit/metainterp/optimizeopt/optimizer.py @@ -279,6 +279,7 @@ class Optimizer(Optimization): self.quasi_immutable_deps = None self.replaces_guard = {} self._newoperations = [] + self._emittedoperations = {} self.optimizer = self self.optpure = None self.optheap = None @@ -288,15 +289,10 @@ class Optimizer(Optimization): self._really_emitted_operation = None self._last_guard_op = None - self._inparg_dict = {} self.set_optimizations(optimizations) self.setup() - def add_to_inparg_dict_from(self, lst): - for box in lst: - self._inparg_dict[box] = None - def set_optimizations(self, optimizations): if optimizations: self.first_optimization = optimizations[0] @@ -387,7 +383,7 @@ class Optimizer(Optimization): def as_operation(self, op): # You should never check "isinstance(op, AbstractResOp" directly. # Instead, use this helper. - if isinstance(op, AbstractResOp) and op not in self._inparg_dict: + if isinstance(op, AbstractResOp) and op in self._emittedoperations: return op return None @@ -407,6 +403,7 @@ class Optimizer(Optimization): def clear_newoperations(self): self._newoperations = [] + self._emittedoperations = {} def make_equal_to(self, op, newop): op = self.get_box_replacement(op) @@ -634,6 +631,7 @@ class Optimizer(Optimization): self._last_guard_op = None self._really_emitted_operation = op self._newoperations.append(op) + self._emittedoperations[op] = None def emit_guard_operation(self, op, pendingfields): guard_op = op # self.replace_op_with(op, op.getopnum()) @@ -678,6 +676,7 @@ class Optimizer(Optimization): return newop = self.replace_op_with_no_ovf(op) self._newoperations[-1] = newop + self._emittedoperations[newop] = None def replace_op_with_no_ovf(self, op): if op.getopnum() == rop.INT_MUL_OVF: @@ -722,6 +721,7 @@ class Optimizer(Optimization): new_descr = new_op.getdescr() new_descr.copy_all_attributes_from(old_descr) self._newoperations[old_op_pos] = new_op + self._emittedoperations[new_op] = None def store_final_boxes_in_guard(self, op, pendingfields): assert pendingfields is not None diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py index fe590b7129..a4bf4d7de9 100644 --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -4017,7 +4017,6 @@ class BaseTestOptimizeBasic(BaseTestBasic): strsetitem(p3, i2, i0) i5 = int_add(i2, 1) strsetitem(p3, i5, i1) - ifoo = int_add(i5, 1) jump(i1, i0, p3) """ self.optimize_strunicode_loop(ops, expected) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py index 3ad352ed39..d7efc69970 100644 --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py @@ -1300,7 +1300,7 @@ class OptimizeOptTest(BaseTestWithUnroll): preamble = """ [i0, p1, p3] i28 = int_add(i0, 1) - i29 = int_add(i28, 1) + i29 = int_add(i0, 2) p30 = new_with_vtable(descr=nodesize) setfield_gc(p30, i28, descr=valuedescr) setfield_gc(p3, p30, descr=nextdescr) @@ -1310,7 +1310,7 @@ class OptimizeOptTest(BaseTestWithUnroll): expected = """ [i0, p1, p3] i28 = int_add(i0, 1) - i29 = int_add(i28, 1) + i29 = int_add(i0, 2) p30 = new_with_vtable(descr=nodesize) setfield_gc(p30, i28, descr=valuedescr) setfield_gc(p3, p30, descr=nextdescr) @@ -6392,7 +6392,6 @@ class OptimizeOptTest(BaseTestWithUnroll): strsetitem(p3, i2, i0) i5 = int_add(i2, 1) strsetitem(p3, i5, i1) - i6 = int_add(i5, 1) # will be killed by the backend jump(i1, i0, p3) """ self.optimize_strunicode_loop(ops, expected, expected) @@ -9063,6 +9062,7 @@ class OptimizeOptTest(BaseTestWithUnroll): self.optimize_loop(ops, expected) def test_same_as_preserves_info_in_the_preamble_2(self): + py.test.xfail("less efficient loop, investigate") ops = """ [i0, p0] ifoo = getfield_gc_i(p0, descr=valuedescr) diff --git a/rpython/jit/metainterp/optimizeopt/unroll.py b/rpython/jit/metainterp/optimizeopt/unroll.py index 170905f515..6f7eaaa4be 100644 --- a/rpython/jit/metainterp/optimizeopt/unroll.py +++ b/rpython/jit/metainterp/optimizeopt/unroll.py @@ -21,7 +21,6 @@ class UnrollableOptimizer(Optimizer): if self.optunroll.short_preamble_producer is None: assert False # unreachable code op = preamble_op.op - #----self.optimizer.inparg_dict[op] = None # XXX ARGH # special hack for int_add(x, accumulator-const) optimization self.optunroll.short_preamble_producer.use_box(op, preamble_op.preamble_op, self) @@ -143,7 +142,6 @@ class UnrollOptimizer(Optimization): except VirtualStatesCantMatch: raise InvalidLoop("Cannot import state, virtual states don't match") self.potential_extra_ops = {} - self.optimizer.add_to_inparg_dict_from(label_args) try: info, _ = self.optimizer.propagate_all_forward( trace, call_pure_results, flush=False) |