[pypy-commit] pypy backend-vector-ops: tests and fixes

fijal noreply at buildbot.pypy.org
Sun Feb 12 22:19:26 CET 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: backend-vector-ops
Changeset: r52398:64ecf22e0e9e
Date: 2012-02-12 23:18 +0200
http://bitbucket.org/pypy/pypy/changeset/64ecf22e0e9e/

Log:	tests and fixes

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_vectorize.py b/pypy/jit/metainterp/optimizeopt/test/test_vectorize.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_vectorize.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_vectorize.py
@@ -27,9 +27,9 @@
     def test_basic(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        call(p0, i0, descr=assert_aligned)
-        call(p1, i1, descr=assert_aligned)
-        call(p1, i2, descr=assert_aligned)
+        call(0, p0, i0, descr=assert_aligned)
+        call(0, p1, i1, descr=assert_aligned)
+        call(0, p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)
@@ -59,9 +59,9 @@
     def test_basic_sub(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        call(p0, i0, descr=assert_aligned)
-        call(p1, i1, descr=assert_aligned)
-        call(p1, i2, descr=assert_aligned)
+        call(0, p0, i0, descr=assert_aligned)
+        call(0, p1, i1, descr=assert_aligned)
+        call(0, p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_sub(f0, f1)
@@ -93,9 +93,9 @@
     def test_unfit_trees(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        call(p0, i0, descr=assert_aligned)
-        call(p1, i1, descr=assert_aligned)
-        call(p1, i2, descr=assert_aligned)
+        call(0, p0, i0, descr=assert_aligned)
+        call(0, p1, i1, descr=assert_aligned)
+        call(0, p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)
@@ -131,9 +131,9 @@
     def test_unfit_trees_2(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        call(p0, i0, descr=assert_aligned)
-        call(p1, i1, descr=assert_aligned)
-        call(p1, i2, descr=assert_aligned)
+        call(0, p0, i0, descr=assert_aligned)
+        call(0, p1, i1, descr=assert_aligned)
+        call(0, p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)
@@ -163,9 +163,9 @@
     def test_unfit_trees_3(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        call(p0, i0, descr=assert_aligned)
-        call(p1, i1, descr=assert_aligned)
-        call(p1, i2, descr=assert_aligned)
+        call(0, p0, i0, descr=assert_aligned)
+        call(0, p1, i1, descr=assert_aligned)
+        call(0, p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)
@@ -199,9 +199,9 @@
     def test_guard_forces(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        call(p0, i0, descr=assert_aligned)
-        call(p1, i1, descr=assert_aligned)
-        call(p1, i2, descr=assert_aligned)
+        call(0, p0, i0, descr=assert_aligned)
+        call(0, p1, i1, descr=assert_aligned)
+        call(0, p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)
@@ -233,14 +233,14 @@
     def test_guard_prevents(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        call(p0, i0, descr=assert_aligned)
-        call(p1, i1, descr=assert_aligned)
-        call(p1, i2, descr=assert_aligned)
+        call(0, p0, i0, descr=assert_aligned)
+        call(0, p1, i1, descr=assert_aligned)
+        call(0, p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)
+        guard_true(i1) [p0, p1, p2, i1, i0, i2, f1, f2]
         setarrayitem_raw(p2, i2, f2, descr=arraydescr)
-        guard_true(i1) [p0, p1, p2, i1, i0, i2, f1, f2]
         i0_1 = int_add(i0, 1)
         i1_1 = int_add(1, i1)
         i2_1 = int_add(i2, 1)
@@ -255,8 +255,8 @@
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)
+        guard_true(i1) [p0, p1, p2, i1, i0, i2, f1, f2]
         setarrayitem_raw(p2, i2, f2, descr=arraydescr)
-        guard_true(i1) [p0, p1, p2, i1, i0, i2, f1, f2]
         i0_1 = int_add(i0, 1)
         i2_1 = int_add(i2, 1)
         f0_1 = getarrayitem_raw(p0, i0_1, descr=arraydescr)
@@ -266,3 +266,10 @@
         finish(p0, p1, p2, i0_1, i2_1)
         """
         self.optimize_loop(ops, expected)
+
+    def test_force_by_box_usage(self):
+        ops = """
+        [p0, p1, p2, i0, i1, i2]
+        call(0, p0, i0, descr=assert_aligned)
+        f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
+        xxx
diff --git a/pypy/jit/metainterp/optimizeopt/vectorize.py b/pypy/jit/metainterp/optimizeopt/vectorize.py
--- a/pypy/jit/metainterp/optimizeopt/vectorize.py
+++ b/pypy/jit/metainterp/optimizeopt/vectorize.py
@@ -101,7 +101,7 @@
     def optimize_CALL(self, op):
         oopspec = self.get_oopspec(op)
         if oopspec == EffectInfo.OS_ASSERT_ALIGNED:
-            index = self.getvalue(op.getarg(1))
+            index = self.getvalue(op.getarg(2))
             self.tracked_indexes[index] = TrackIndex(index, 0)
         else:
             self.optimize_default(op)
@@ -165,7 +165,7 @@
 
     def emit_vector_ops(self, forbidden_boxes):
         for arg in forbidden_boxes:
-            if arg in self.track:
+            if self.getvalue(arg) in self.track:
                 self.reset()
                 return
         if self.full:
@@ -181,7 +181,7 @@
             for arr, items in self.full.iteritems():
                 items[0].emit(self)
             self.ops_so_far = []
-            self.reset()
+        self.reset()
             
     def optimize_default(self, op):
         # list operations that are fine, not that many
diff --git a/pypy/module/micronumpy/signature.py b/pypy/module/micronumpy/signature.py
--- a/pypy/module/micronumpy/signature.py
+++ b/pypy/module/micronumpy/signature.py
@@ -152,9 +152,10 @@
     def eval(self, frame, arr):
         iter = frame.iterators[self.iter_no]
         offset = iter.offset
+        arr = frame.arrays[self.array_no]
         if frame.first_iteration:
-            jit.assert_aligned(offset)
-        return self.dtype.getitem(frame.arrays[self.array_no], offset)
+            jit.assert_aligned(arr, offset)
+        return self.dtype.getitem(arr, offset)
 
 class ScalarSignature(ConcreteSignature):
     def debug_repr(self):
diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py
--- a/pypy/rlib/jit.py
+++ b/pypy/rlib/jit.py
@@ -872,6 +872,7 @@
         return hop.genop('jit_record_known_class', [v_inst, v_cls],
                          resulttype=lltype.Void)
 
- at oopspec('assert_aligned(arg)')
-def assert_aligned(arg):
-    keepalive_until_here(arg)
+ at oopspec('assert_aligned(arr, index)')
+def assert_aligned(arr, index):
+    keepalive_until_here(arr)
+    keepalive_until_here(index)


More information about the pypy-commit mailing list