Commit 0cb67cdc authored by Carl Friedrich Bolz-Tereick's avatar Carl Friedrich Bolz-Tereick
Browse files

test and fix: we can't reuse results of non-ovfcheck operations for ovfcheck

operations (only in the over direction)

--HG--
branch : fix-intutils-ovf-bug
parent 0746a151eb62
......@@ -72,7 +72,7 @@ class RecentPureOps(object):
box1.same_box(get_box_replacement(op.getarg(1))) and
op.getdescr() is descr):
op = self.force_preamble_op(opt, op, i)
return get_box_replacement(op)
return op
return None
def lookup(self, optimizer, op):
......@@ -104,6 +104,7 @@ class OptPure(Optimization):
def optimize_default(self, op):
canfold = rop.is_always_pure(op.opnum)
ovf = False
if rop.is_ovf(op.opnum):
self.postponed_op = op
return
......@@ -112,6 +113,7 @@ class OptPure(Optimization):
op = self.postponed_op
self.postponed_op = None
canfold = nextop.getopnum() == rop.GUARD_NO_OVERFLOW
ovf = True
else:
nextop = None
......@@ -132,7 +134,9 @@ class OptPure(Optimization):
recentops = self.getrecentops(op.getopnum())
save = True
oldop = recentops.lookup(self.optimizer, op)
if oldop is not None:
# careful! if this is an ovf operation we can only re-use the
# result of a prior ovf operation (the other direction is fine)
if oldop is not None and (not ovf or oldop.opnum == op.opnum):
self.optimizer.make_equal_to(op, oldop)
return
......
......@@ -1970,6 +1970,16 @@ class TestOptimizeIntBounds(BaseTestBasic):
"""
self.optimize_loop(ops, expected)
def test_pure_ovf_bug(self):
ops = """
[i1, i2]
i3 = int_add(i2, i1)
i4 = int_sub_ovf(i3, i2)
guard_no_overflow() []
jump(i4)
"""
self.optimize_loop(ops, ops)
class TestComplexIntOpts(BaseTestBasic):
def test_intdiv_bounds(self):
......
Supports Markdown
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