Commits

Maciej Fijalkowski committed 64ecf22

tests and fixes

Comments (0)

Files changed (4)

pypy/jit/metainterp/optimizeopt/test/test_vectorize.py

     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)
     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)
     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)
     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)
     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)
     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)
     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)
         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)
         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

pypy/jit/metainterp/optimizeopt/vectorize.py

     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)
 
     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:
             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

pypy/module/micronumpy/signature.py

     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):
         return hop.genop('jit_record_known_class', [v_inst, v_cls],
                          resulttype=lltype.Void)
 
-@oopspec('assert_aligned(arg)')
-def assert_aligned(arg):
-    keepalive_until_here(arg)
+@oopspec('assert_aligned(arr, index)')
+def assert_aligned(arr, index):
+    keepalive_until_here(arr)
+    keepalive_until_here(index)