Author: Brian Kearns <[email protected]>
Branch:
Changeset: r74848:dba4524de78e
Date: 2014-12-05 16:17 -0500
http://bitbucket.org/pypy/pypy/changeset/dba4524de78e/
Log: add test_zjit for logical_xor reduce
diff --git a/pypy/module/micronumpy/compile.py
b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -33,7 +33,7 @@
pass
-SINGLE_ARG_FUNCTIONS = ["sum", "prod", "max", "min", "all", "any",
+SINGLE_ARG_FUNCTIONS = ["sum", "prod", "max", "min", "all", "any", "xor",
"unegative", "flat", "tostring", "count_nonzero",
"argsort", "cumsum"]
TWO_ARG_FUNCTIONS = ["dot", 'take', 'searchsorted']
@@ -561,6 +561,9 @@
w_res = arr.descr_all(interp.space)
elif self.name == "cumsum":
w_res = arr.descr_cumsum(interp.space)
+ elif self.name == "xor":
+ xor = ufuncs.get(interp.space).logical_xor
+ w_res = xor.reduce(interp.space, arr, None)
elif self.name == "unegative":
neg = ufuncs.get(interp.space).negative
w_res = neg.call(interp.space, [arr])
diff --git a/pypy/module/micronumpy/test/test_zjit.py
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -400,6 +400,7 @@
def test_all(self):
result = self.run("all")
assert result == 1
+ self.check_trace_count(1)
self.check_simple_loop({
'cast_float_to_int': 1,
'guard_false': 1,
@@ -412,6 +413,36 @@
'raw_load': 1,
})
+ def define_logical_xor_reduce():
+ return """
+ a = [1,1,1,1,1,1,1,1]
+ xor(a)
+ """
+
+ def test_logical_xor_reduce(self):
+ result = self.run("logical_xor_reduce")
+ assert result == 0
+ self.check_trace_count(2)
+ # XXX fix this
+ self.check_simple_loop({
+ 'cast_float_to_int': 1,
+ 'getfield_gc': 2,
+ 'getfield_gc_pure': 11,
+ 'guard_class': 1,
+ 'guard_false': 2,
+ 'guard_not_invalidated': 1,
+ 'guard_true': 4,
+ 'int_add': 2,
+ 'int_and': 1,
+ 'int_ge': 1,
+ 'int_is_true': 3,
+ 'int_xor': 1,
+ 'jump': 1,
+ 'new_with_vtable': 1,
+ 'raw_load': 1,
+ 'setfield_gc': 4,
+ })
+
def define_already_forced():
return """
a = |30|
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit