Author: Richard Plangger <r...@pasra.at>
Branch: vecopt2
Changeset: r77112:28e240f91ac9
Date: 2015-04-10 17:13 +0200
http://bitbucket.org/pypy/pypy/changeset/28e240f91ac9/

Log:    updated the vectorizer to use the new dependency graph, not yet
        finished (simplifications included)

diff --git a/rpython/jit/metainterp/optimizeopt/dependency.py 
b/rpython/jit/metainterp/optimizeopt/dependency.py
--- a/rpython/jit/metainterp/optimizeopt/dependency.py
+++ b/rpython/jit/metainterp/optimizeopt/dependency.py
@@ -159,6 +159,8 @@
         while len(worklist) > 0:
             node = worklist.pop()
             for dep in node.provides():
+                if dep.to.is_after(other):
+                    continue
                 if dep.points_to(other):
                     # dependent. There is a path from self to other
                     return False
@@ -168,6 +170,8 @@
         while len(worklist) > 0:
             node = worklist.pop()
             for dep in node.depends():
+                if dep.to.is_before(other):
+                    continue
                 if dep.points_to(other):
                     # dependent. There is a path from self to other
                     return False
@@ -218,9 +222,8 @@
         return not self.__eq__(other)
 
     def __eq__(self, other):
-        if isinstance(other, Node):
-            return self.opidx == other.opidx
-        return False
+        assert isinstance(other, Node)
+        return self.opidx == other.opidx
 
 
 class Dependency(object):
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_vectorize.py 
b/rpython/jit/metainterp/optimizeopt/test/test_vectorize.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_vectorize.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_vectorize.py
@@ -809,7 +809,11 @@
         """.format(op=op,descr=descr,stride=stride)
         loop = self.parse_loop(ops)
         vopt = self.combine_packset(loop,3)
+        self.debug_print_operations(loop)
         assert len(vopt.dependency_graph.memory_refs) == 12
+        if len(vopt.packset.packs) != 4:
+            for pack in vopt.packset.packs:
+                print vopt.packset.packs
         assert len(vopt.packset.packs) == 4
 
         for opindices in [(4,11,18,25),(5,12,19,26),
diff --git a/rpython/jit/metainterp/optimizeopt/vectorize.py 
b/rpython/jit/metainterp/optimizeopt/vectorize.py
--- a/rpython/jit/metainterp/optimizeopt/vectorize.py
+++ b/rpython/jit/metainterp/optimizeopt/vectorize.py
@@ -35,7 +35,7 @@
 
 def must_unpack_result_to_exec(op, target_op):
     # TODO either move to resop or util
-    if op.vector != -1:
+    if op.getoperation().vector != -1:
         return False
     return True
 
@@ -279,6 +279,7 @@
                             self.packset.add_pair(node_a, node_b)
 
     def extend_packset(self):
+        print "extend_packset"
         pack_count = self.packset.pack_count()
         while True:
             for pack in self.packset.packs:
@@ -294,7 +295,7 @@
             for rdep in pack.right.depends():
                 lnode = ldep.to
                 rnode = rdep.to
-                if lnode != rnode and self.packset.can_be_packed(lnode, rnode):
+                if lnode.is_before(rnode) and 
self.packset.can_be_packed(lnode, rnode):
                     savings = self.packset.estimate_savings(lnode, rnode, 
pack, False)
                     if savings >= 0:
                         self.packset.add_pair(lnode, rnode)
@@ -302,12 +303,12 @@
     def follow_def_uses(self, pack):
         assert isinstance(pack, Pair)
         savings = -1
-        candidate = (-1,-1, None, None)
-        for ldep in pack.left.depends():
-            for rdep in pack.right.depends():
+        candidate = (-1,-1)
+        for ldep in pack.left.provides():
+            for rdep in pack.right.provides():
                 lnode = ldep.to
                 rnode = rdep.to
-                if lnode != rnode and \
+                if lnode.is_before(rnode) and \
                    self.packset.can_be_packed(lnode, rnode):
                     est_savings = \
                         self.packset.estimate_savings(lnode, rnode, pack, True)
@@ -535,6 +536,7 @@
         return len(self.packs)
 
     def add_pair(self, l, r):
+        print "adds", l, r
         self.packs.append(Pair(l,r))
 
     def can_be_packed(self, lnode, rnode):
@@ -542,13 +544,13 @@
             if lnode.independent(rnode):
                 for pack in self.packs:
                     # TODO save pack on Node
-                    if pack.left.opidx == lnode.getindex() or \
-                       pack.right.opidx == rnode.getindex():
+                    if pack.left.getindex()== lnode.getindex() or \
+                       pack.right.getindex() == rnode.getindex():
                         return False
                 return True
         return False
 
-    def estimate_savings(self, lopidx, ropidx, pack, expand_forward):
+    def estimate_savings(self, lnode, rnode, pack, expand_forward):
         """ Estimate the number of savings to add this pair.
         Zero is the minimum value returned. This should take
         into account the benefit of executing this instruction
@@ -557,20 +559,18 @@
         savings = -1
 
         # without loss of generatlity: only check 'left' operation
-        lop = self.operations[lopidx]
-        target_op = self.operations[pack.left.opidx]
-
-        if prohibit_packing(lop, target_op):
+        lpacknode = pack.left
+        if prohibit_packing(lnode.getoperation(), lpacknode.getoperation()):
             return -1
 
         if not expand_forward:
             #print " backward savings", savings
-            if not must_unpack_result_to_exec(target_op, lop):
+            if not must_unpack_result_to_exec(lpacknode, lnode):
                 savings += 1
             #print " => backward savings", savings
         else:
             #print " forward savings", savings
-            if not must_unpack_result_to_exec(target_op, lop):
+            if not must_unpack_result_to_exec(lpacknode, lnode):
                 savings += 1
             #print " => forward savings", savings
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to