Commits

Carl Friedrich Bolz committed 3eb981d

make sure that if you tag the same thing twice you reuse the result

Comments (0)

Files changed (2)

pypy/jit/metainterp/optimizeopt/intbounds.py

                 maxbounds = IntBound((-sys.maxint-1) >> 1, sys.maxint >> 1)
                 v1.intbound.intersect(maxbounds)
                 self.pure(rop.INT_UNTAG, [result], args[0])
+                self.pure(rop.INT_TAG, args[:], result)
         self.emit_operation(op)
 
     def optimize_GUARD_OVERFLOW(self, op):

pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py

         """
         self.optimize_loop(ops, expected, preamble)
 
+    def test_int_tag_ovf_not_repeated(self):
+        ops = """
+        [i0]
+        i1 = int_tag_ovf(i0)
+        guard_no_overflow() []
+        i2 = int_tag_ovf(i0)
+        guard_no_overflow() []
+        i5 = int_add(i2, 1)
+        escape(i5)
+        jump(i5)
+        """
+        expected = """
+        [i0]
+        i1 = int_tag_ovf(i0)
+        guard_no_overflow() []
+        i5 = int_add(i1, 1)
+        escape(i5)
+        jump(i5)
+        """
+        self.optimize_loop(ops, expected)
+
+
     def test_mul_ovf(self):
         ops = """
         [i0, i1]