[pypy-commit] pypy jit-short_from_state: produce the value guards for the short preamble prior to inlining the peeled loop as that might strengthen the values of the inputargs and thus make the value guards in the short preamble too strong

hakanardo noreply at buildbot.pypy.org
Wed Jul 13 17:00:23 CEST 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-short_from_state
Changeset: r45561:05ccf7b80667
Date: 2011-07-13 16:59 +0200
http://bitbucket.org/pypy/pypy/changeset/05ccf7b80667/

Log:	produce the value guards for the short preamble prior to inlining
	the peeled loop as that might strengthen the values of the inputargs
	and thus make the value guards in the short preamble too strong

diff --git a/pypy/jit/metainterp/optimizeopt/generalize.py b/pypy/jit/metainterp/optimizeopt/generalize.py
--- a/pypy/jit/metainterp/optimizeopt/generalize.py
+++ b/pypy/jit/metainterp/optimizeopt/generalize.py
@@ -14,5 +14,4 @@
                 v.intbound.lower = MININT
             if v.intbound.upper > MAXINT/2:
                 v.intbound.upper = MAXINT
-        import pdb; pdb.set_trace()
           
diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -275,6 +275,17 @@
         short_jumpargs = inputargs[:]
         short_inputargs = virtual_state.make_inputargs(values, keyboxes=True)
 
+        short = []
+        short_seen = {}
+        for box, const in self.constant_inputargs.items():
+            short_seen[box] = True
+        
+        for result, op in self.short_boxes.items():
+            if op is not None:
+                assert result is op.result
+                for guard in self.getvalue(result).make_guards(result):
+                    self.add_op_to_short(guard, short, short_seen, False)
+
         # This loop is equivalent to the main optimization loop in
         # Optimizer.propagate_all_forward
         jumpop = None
@@ -297,18 +308,13 @@
         jmp_to_short_args = virtual_state.make_inputargs(values, keyboxes=True)
         self.short_inliner = Inliner(short_inputargs, jmp_to_short_args)
         
-        short = []
-        short_seen = {}
         for box, const in self.constant_inputargs.items():
-            short_seen[box] = True
             self.short_inliner.argmap[box] = const
+
+        for op in short:
+            newop = self.short_inliner.inline_op(op)
+            self.optimizer.send_extra_operation(newop)
         
-        for result, op in self.short_boxes.items():
-            if op is not None:
-                assert result is op.result
-                if len(self.getvalue(result).make_guards(result)) > 0:
-                    self.add_op_to_short(op, short, short_seen)
-
         self.optimizer.flush()
                     
 
@@ -356,35 +362,35 @@
         
         return inputargs, short_inputargs, short
 
-    def add_op_to_short(self, op, short, short_seen):
+    def add_op_to_short(self, op, short, short_seen, emit=True):
         if op is None:
-            return
+            return None
         if op.result is not None and op.result in short_seen:
-            return self.short_inliner.inline_arg(op.result)
+            if emit:
+                return self.short_inliner.inline_arg(op.result)
+            else:
+                return None
         for a in op.getarglist():
             if not isinstance(a, Const) and a not in short_seen:
-                self.add_op_to_short(self.short_boxes[a], short, short_seen)
+                self.add_op_to_short(self.short_boxes[a], short, short_seen, emit)
         if op.is_guard():
             descr = self.start_resumedescr.clone_if_mutable()
             op.setdescr(descr)
 
-        value_guards = []
-        if op.result in self.short_boxes:
-            value_guards = self.getvalue(op.result).make_guards(op.result)
-
         short.append(op)
         short_seen[op.result] = True
-        newop = self.short_inliner.inline_op(op)
-        self.optimizer.send_extra_operation(newop)
+        if emit:
+            newop = self.short_inliner.inline_op(op)
+            self.optimizer.send_extra_operation(newop)
 
         if op.is_ovf():
             # FIXME: ensure that GUARD_OVERFLOW:ed ops not end up here
             guard = ResOperation(rop.GUARD_NO_OVERFLOW, [], None)
-            self.add_op_to_short(guard, short, short_seen)
-        for guard in value_guards:
-            self.add_op_to_short(guard, short, short_seen)
+            self.add_op_to_short(guard, short, short_seen, emit)
 
-        return newop.result
+        if emit:
+            return newop.result
+        return None
         
     def import_box(self, box, inputargs, short, short_jumpargs,
                    jumpargs, short_seen):


More information about the pypy-commit mailing list