[pypy-commit] pypy vecopt-merge: added llgraph impl for int_and int_or (vector ops), added a test to ensure the assembler to work correctly with the scalar unpacked value

plan_rich noreply at buildbot.pypy.org
Thu Oct 1 20:57:25 CEST 2015


Author: Richard Plangger <planrichi at gmail.com>
Branch: vecopt-merge
Changeset: r79924:7499f3065b10
Date: 2015-10-01 20:57 +0200
http://bitbucket.org/pypy/pypy/changeset/7499f3065b10/

Log:	added llgraph impl for int_and int_or (vector ops), added a test to
	ensure the assembler to work correctly with the scalar unpacked
	value

diff --git a/rpython/jit/backend/llgraph/runner.py b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -799,6 +799,8 @@
     exec py.code.Source(vector_arith_code.format('int','add','+')).compile()
     exec py.code.Source(vector_arith_code.format('int','sub','-')).compile()
     exec py.code.Source(vector_arith_code.format('int','mul','*')).compile()
+    exec py.code.Source(vector_arith_code.format('int','and','&')).compile()
+    exec py.code.Source(vector_arith_code.format('int','or','|')).compile()
     exec py.code.Source(vector_arith_code.format('float','add','+')).compile()
     exec py.code.Source(vector_arith_code.format('float','sub','-')).compile()
     exec py.code.Source(vector_arith_code.format('float','mul','*')).compile()
diff --git a/rpython/jit/metainterp/test/test_vector.py b/rpython/jit/metainterp/test/test_vector.py
--- a/rpython/jit/metainterp/test/test_vector.py
+++ b/rpython/jit/metainterp/test/test_vector.py
@@ -386,5 +386,28 @@
         res = self.meta_interp(f, [size], vec_all=True)
         assert res == f(size)
 
+    def test_max_byte(self):
+        myjitdriver = JitDriver(greens = [], reds = 'auto')
+        T = lltype.Array(rffi.SIGNEDCHAR, hints={'nolength': True})
+        def f(size):
+            vector_a = malloc(T, size)
+            for i in range(size):
+                vector_a[i] = rffi.r_signedchar(1)
+            for i in range(size/2,size):
+                vector_a[i] = rffi.r_signedchar(i)
+            i = 0
+            max = -127
+            while i < size:
+                myjitdriver.jit_merge_point()
+                a = intmask(vector_a[i])
+                a = a & 255
+                if a > max:
+                    max = a
+                i += 1
+            free(vector_a)
+            return max
+        res = self.meta_interp(f, [128], vec_all=True)
+        assert res == f(128)
+
 class TestLLtype(LLJitMixin, VectorizeTests):
     pass


More information about the pypy-commit mailing list