[pypy-commit] pypy int-tag-untag-as-operations: test and fix: make constand-folding of int_tag not crash

cfbolz noreply at buildbot.pypy.org
Fri Nov 25 12:54:21 CET 2011


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: int-tag-untag-as-operations
Changeset: r49788:8c0f8d14997a
Date: 2011-11-17 16:56 +0100
http://bitbucket.org/pypy/pypy/changeset/8c0f8d14997a/

Log:	test and fix: make constand-folding of int_tag not crash

diff --git a/pypy/jit/metainterp/optimizeopt/intbounds.py b/pypy/jit/metainterp/optimizeopt/intbounds.py
--- a/pypy/jit/metainterp/optimizeopt/intbounds.py
+++ b/pypy/jit/metainterp/optimizeopt/intbounds.py
@@ -307,9 +307,7 @@
 
     def optimize_INT_TAG_OVF(self, op):
         v1 = self.getvalue(op.getarg(0))
-        r = self.getvalue(op.result)
         resbound = v1.intbound.mul(2).add(1)
-        r.intbound.intersect(resbound)
         if resbound.bounded():
             op = op.copy_and_change(rop.INT_TAG)
             self.optimize_INT_TAG(op) # emit the op
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -5248,6 +5248,27 @@
         """
         self.optimize_loop(ops, expected)
 
+    def test_int_tag_constfold(self):
+        ops = """
+        [i0]
+        i1 = int_tag_ovf(1)
+        guard_no_overflow() []
+        i4 = int_untag(i1)
+        i5 = int_add(i4, 1)
+        escape(i5)
+        jump(i5)
+        """
+        expected = """
+        []
+        escape(2)
+        jump()
+        """
+        preamble = """
+        [i0]
+        escape(2)
+        jump()
+        """
+        self.optimize_loop(ops, expected, preamble)
 
     def test_mul_ovf(self):
         ops = """


More information about the pypy-commit mailing list