Commits

Maciej Fijalkowski committed f51969a

guard support and a fix

Comments (0)

Files changed (2)

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

         """
         self.optimize_loop(ops, expected)
         
+    def test_guard_forces(self):
+        ops = """
+        [p0, p1, p2, i0, i1, i2]
+        assert_aligned(p0, i0)
+        assert_aligned(p1, i1)
+        assert_aligned(p1, i2)
+        f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
+        f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
+        f2 = float_add(f0, f1)
+        setarrayitem_raw(p2, i2, f2, descr=arraydescr)
+        i0_1 = int_add(i0, 1)
+        i1_1 = int_add(1, i1)
+        i2_1 = int_add(i2, 1)
+        f0_1 = getarrayitem_raw(p0, i0_1, descr=arraydescr)
+        f1_1 = getarrayitem_raw(p1, i1_1, descr=arraydescr)
+        f2_1 = float_add(f0_1, f1_1)
+        setarrayitem_raw(p2, i2_1, f2_1, descr=arraydescr)
+        guard_true(i2_1) [p0, p1, p2, i0_1, i1_1, i2_1]
+        finish(p0, p1, p2, i0_1, i1_1)
+        """
+        expected = """
+        [p0, p1, p2, i0, i1, i2]
+        i0_1 = int_add(i0, 1)
+        i1_1 = int_add(1, i1)
+        i2_1 = int_add(i2, 1)
+        vec0 = getarrayitem_vector_raw(p0, i0, descr=arraydescr)
+        vec1 = getarrayitem_vector_raw(p1, i1, descr=arraydescr)
+        vec2 = float_vector_add(vec0, vec1)
+        setarrayitem_vector_raw(p2, i2, vec2, descr=arraydescr)
+        guard_true(i2_1) [p0, p1, p2, i0_1, i1_1, i2_1]
+        finish(p0, p1, p2, i0_1, i1_1)
+        """
+        self.optimize_loop(ops, expected)
+
+    def test_guard_prevents(self):
+        ops = """
+        [p0, p1, p2, i0, i1, i2]
+        assert_aligned(p0, i0)
+        assert_aligned(p1, i1)
+        assert_aligned(p1, i2)
+        f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
+        f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
+        f2 = float_add(f0, f1)
+        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_1 = getarrayitem_raw(p0, i0_1, descr=arraydescr)
+        f1_1 = getarrayitem_raw(p1, i1_1, descr=arraydescr)
+        f2_1 = float_add(f0_1, f1_1)
+        setarrayitem_raw(p2, i2_1, f2_1, descr=arraydescr)
+        finish(p0, p1, p2, i0_1, i2_1)
+        """
+        expected = """
+        [p0, p1, p2, i0, i1, i2]
+        f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
+        f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
+        f2 = float_add(f0, f1)
+        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)
+        f1_1 = getarrayitem_raw(p1, 2, descr=arraydescr)
+        f2_1 = float_add(f0_1, f1_1)
+        setarrayitem_raw(p2, i2_1, f2_1, descr=arraydescr)
+        finish(p0, p1, p2, i0_1, i2_1)
+        """
+        self.optimize_loop(ops, expected)

pypy/jit/metainterp/optimizeopt/vectorize.py

             for arr, items in self.full.iteritems():
                 items[0].emit(self)
             self.ops_so_far = []
-
+            self.reset()
+            
     def optimize_default(self, op):
         # list operations that are fine, not that many
         if op.opnum in [rop.JUMP, rop.FINISH, rop.LABEL]:
             self.emit_vector_ops(op.getarglist())
         elif op.is_guard():
-            xxx
+            self.emit_vector_ops(op.getarglist() + op.getfailargs())
         elif op.is_always_pure():
             # in theory no side effect ops, but stuff like malloc
             # can go in the way