Commits

Maciej Fijalkowski committed bb1957c

a failing test and a simplification

Comments (0)

Files changed (2)

pypy/jit/backend/test/runner_test.py

         assert a[0] == 26
         assert a[1] == 30
         lltype.free(a, flavor='raw')
+
+    def test_vector_ops_interiorfield(self):
+        if not self.cpu.supports_vector_ops:
+            py.test.skip("unsupported vector ops")
         
+        A = lltype.Array(lltype.Float, hints={'nolength': True,
+                                               'memory_position_alignment': 16})
+        fsize = rffi.sizeof(lltype.Float)
+        descr0 = self.cpu.interiorfielddescrof_dynamic(0, 1, fsize, False, True,
+                                                       False)
+        looptoken = JitCellToken()
+        ops = parse("""
+        [p0, p1]
+        vec0 = getarrayitem_vector_raw(p0, 0, descr=descr0)
+        vec1 = getarrayitem_vector_raw(p1, 0, descr=descr0)
+        vec2 = float_vector_add(vec0, vec1)
+        setarrayitem_vector_raw(p0, 0, vec2, descr=descr0)
+        finish()
+        """, namespace=locals())
+        self.cpu.compile_loop(ops.inputargs, ops.operations, looptoken)
+        a = lltype.malloc(A, 10, flavor='raw')
+        a[0] = 13.0
+        a[1] = 15.0
+        self.cpu.execute_token(looptoken, a, a)
+        assert a[0] == 26
+        assert a[1] == 30
+        lltype.free(a, flavor='raw')
+
 
 class OOtypeBackendTest(BaseBackendTest):
 

pypy/jit/backend/x86/regalloc.py

         ofs = arraydescr.basesize
         size = arraydescr.itemsize
         sign = arraydescr.is_item_signed()
-        return size, ofs, sign
+        return imm(size), imm(ofs), sign
 
     def _unpack_fielddescr(self, fielddescr):
         assert isinstance(fielddescr, FieldDescr)
         itemsize, ofs, _ = self._unpack_arraydescr(op.getdescr())
         args = op.getarglist()
         base_loc  = self.rm.make_sure_var_in_reg(op.getarg(0), args)
-        if itemsize == 1:
+        if itemsize.value == 1:
             need_lower_byte = True
         else:
             need_lower_byte = False
         ofs_loc = self.rm.make_sure_var_in_reg(op.getarg(1), args)
         self.possibly_free_vars(args)
         self.PerformDiscard(op, [base_loc, ofs_loc, value_loc,
-                                 imm(itemsize), imm(ofs)])
+                                 itemsize, ofs])
 
     consider_setarrayitem_raw = consider_setarrayitem_gc
     consider_setarrayitem_vector_raw = consider_setarrayitem_gc
             sign_loc = imm1
         else:
             sign_loc = imm0
-        self.Perform(op, [base_loc, ofs_loc, imm(itemsize), imm(ofs),
+        self.Perform(op, [base_loc, ofs_loc, itemsize, ofs,
                           sign_loc], result_loc)
 
     consider_getarrayitem_raw = consider_getarrayitem_gc