[pypy-commit] pypy bounds-int-add-or: implement optimization and fix the test

squeaky noreply at buildbot.pypy.org
Mon Feb 17 23:59:01 CET 2014


Author: Squeaky <squeaky_pl at gmx.com>
Branch: bounds-int-add-or
Changeset: r69192:0e8fc6825162
Date: 2014-02-17 16:55 +0100
http://bitbucket.org/pypy/pypy/changeset/0e8fc6825162/

Log:	implement optimization and fix the test

diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py
--- a/rpython/jit/metainterp/optimizeopt/intbounds.py
+++ b/rpython/jit/metainterp/optimizeopt/intbounds.py
@@ -68,6 +68,19 @@
     optimize_GUARD_FALSE = optimize_GUARD_TRUE
     optimize_GUARD_VALUE = optimize_GUARD_TRUE
 
+    def optimize_INT_OR(self, op):
+        v1 = self.getvalue(op.getarg(0))
+        v2 = self.getvalue(op.getarg(1))
+        self.emit_operation(op)
+        r = self.getvalue(op.result)
+
+        if v1.intbound.lower >= 0 and v2.intbound.lower >= 0:
+            mostsignificant = v1.intbound.upper | v2.intbound.upper
+            # check if next_power2 won't overflow
+            if mostsignificant < (1 << ((symbolic.WORD - 1) << 3)):
+                r.intbound.intersect(
+                    IntBound(0, next_power2(mostsignificant) - 1))
+
     def optimize_INT_XOR(self, op):
         v1 = self.getvalue(op.getarg(0))
         v2 = self.getvalue(op.getarg(1))


More information about the pypy-commit mailing list