Author: Maciej Fijalkowski <fij...@gmail.com>
Branch: optresult
Changeset: r77569:6cd831e762f8
Date: 2015-05-26 12:21 +0200
http://bitbucket.org/pypy/pypy/changeset/6cd831e762f8/

Log:    unify some more

diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py 
b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -561,9 +561,14 @@
     def clear_newoperations(self):
         self._newoperations = []
 
-    def make_equal_to(self, op, oldop):
-        assert op.get_forwarded() is None
-        op.set_forwarded(oldop)
+    def make_equal_to(self, op, newop):
+        opinfo = op.get_forwarded()
+        if opinfo is not None:
+            assert isinstance(opinfo, info.AbstractInfo)
+            op.set_forwarded(newop)
+            newop.set_forwarded(opinfo)
+        else:
+            op.set_forwarded(newop)
 
     def replace_op_with(self, op, newopnum, args=None, descr=None):
         newop = op.copy_and_change(newopnum, args, descr)
diff --git a/rpython/jit/metainterp/optimizeopt/pure.py 
b/rpython/jit/metainterp/optimizeopt/pure.py
--- a/rpython/jit/metainterp/optimizeopt/pure.py
+++ b/rpython/jit/metainterp/optimizeopt/pure.py
@@ -22,7 +22,7 @@
             op = self.lst[i]
             if op is None:
                 break
-            if op.getarg(0).same_box(box0) and op.getdescr() is descr:
+            if opt.get_box_replacement(op.getarg(0)).same_box(box0) and 
op.getdescr() is descr:
                 return opt.get_box_replacement(op)
         return None
 
@@ -31,7 +31,7 @@
             op = self.lst[i]
             if op is None:
                 break
-            if (op.getarg(0).same_box(box0) and op.getarg(1).same_box(box1)
+            if (opt.get_box_replacement(op.getarg(0)).same_box(box0) and 
opt.get_box_replacement(op.getarg(1)).same_box(box1)
                 and op.getdescr() is descr):
                 return opt.get_box_replacement(op)
         return None
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py 
b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -250,14 +250,24 @@
         self.optimizer.pure_reverse(op)
 
     def optimize_guard(self, op, constbox, emit_operation=True):
-        box = self.get_box_replacement(op.getarg(0))
-        if box.is_constant():
-            assert isinstance(box, Const)
-            if not box.same_constant(constbox):
-                r = self.optimizer.metainterp_sd.logger_ops.repr_of_resop(op)
-                raise InvalidLoop('A GUARD_{VALUE,TRUE,FALSE} (%s) was proven '
-                                  'to always fail' % r)
-            return
+        box = op.getarg(0)
+        if box.type == 'i':
+            intbound = self.getintbound(box)
+            if intbound.is_constant():
+                if not intbound.getint() == constbox.getint():
+                    r = self.optimizer.metainterp_sd.logger_ops.repr_of_resop(
+                        op)
+                    raise InvalidLoop('A GUARD_{VALUE,TRUE,FALSE} (%s) was '
+                                      'proven to always fail' % r)
+                return
+        elif box.type == 'r':
+            box = self.get_box_replacement(box)
+            if box.is_constant():
+                if not box.same_constant(constbox):
+                    raise InvalidLoop('A GUARD_VALUE (%s) was proven '
+                                      'to always fail' % r)
+                return
+                    
         if emit_operation:
             self.emit_operation(op)
         self.make_constant(box, constbox)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to