[pypy-commit] pypy vecopt-merge: fixing tests in metainterp/test
plan_rich
noreply at buildbot.pypy.org
Tue Sep 29 17:25:33 CEST 2015
Author: Richard Plangger <planrichi at gmail.com>
Branch: vecopt-merge
Changeset: r79897:084da9225f35
Date: 2015-09-29 17:25 +0200
http://bitbucket.org/pypy/pypy/changeset/084da9225f35/
Log: fixing tests in metainterp/test
diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py b/rpython/jit/metainterp/optimizeopt/schedule.py
--- a/rpython/jit/metainterp/optimizeopt/schedule.py
+++ b/rpython/jit/metainterp/optimizeopt/schedule.py
@@ -216,11 +216,17 @@
class OpMatchSizeTypeFirst(OpRestrict):
def check_operation(self, state, pack, op):
- arg0 = op.getarg(0)
+ i = 0
+ arg0 = op.getarg(i)
+ while arg0.is_constant() and i < op.numargs():
+ i += 1
+ arg0 = op.getarg(i)
bytesize = arg0.bytesize
datatype = arg0.datatype
for arg in op.getarglist():
+ if arg.is_constant():
+ continue
if arg.bytesize != bytesize:
raise NotAVectorizeableLoop()
if arg.datatype != datatype:
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -20,7 +20,7 @@
b1 = InputArgInt()
opt = optimizeopt.Optimizer(FakeMetaInterpStaticData(LLtypeMixin.cpu),
None, None)
- op = ResOperation(rop.GUARD_TRUE, ['dummy'], None)
+ op = ResOperation(rop.GUARD_TRUE, [ConstInt(1)], None)
# setup rd data
fi0 = resume.FrameInfo(None, "code0", 11)
snapshot0 = resume.Snapshot(None, [b0])
diff --git a/rpython/jit/metainterp/test/test_resoperation.py b/rpython/jit/metainterp/test/test_resoperation.py
--- a/rpython/jit/metainterp/test/test_resoperation.py
+++ b/rpython/jit/metainterp/test/test_resoperation.py
@@ -56,13 +56,15 @@
assert INT_SUB.__bases__[0] is BinaryPlainResOp
def test_instantiate():
- op = rop.ResOperation(rop.rop.INT_ADD, ['a', 'b'])
- assert op.getarglist() == ['a', 'b']
+ a = ConstInt(1)
+ b = ConstInt(2)
+ op = rop.ResOperation(rop.rop.INT_ADD, [a, b])
+ assert op.getarglist() == [a, b]
#assert re.match(".*= int_add(a, b)", repr(op))
mydescr = AbstractDescr()
- op = rop.ResOperation(rop.rop.CALL_I, ['a', 'b'], descr=mydescr)
- assert op.getarglist() == ['a', 'b']
+ op = rop.ResOperation(rop.rop.CALL_I, [a, b], descr=mydescr)
+ assert op.getarglist() == [a, b]
assert op.getdescr() is mydescr
#assert re.match(".* = call\(a, b, descr=<.+>\)$", repr(op))
@@ -71,28 +73,39 @@
#assert re.match("guard_no_exception\(descr=<.+>\)$", repr(op))
def test_can_malloc():
+ a = ConstInt(1)
+ b = ConstInt(2)
mydescr = AbstractDescr()
assert rop.ResOperation(rop.rop.NEW, []).can_malloc()
- call = rop.ResOperation(rop.rop.CALL_N, ['a', 'b'], descr=mydescr)
+ call = rop.ResOperation(rop.rop.CALL_N, [a, b], descr=mydescr)
assert call.can_malloc()
- assert not rop.ResOperation(rop.rop.INT_ADD, ['a', 'b']).can_malloc()
+ assert not rop.ResOperation(rop.rop.INT_ADD, [a, b]).can_malloc()
def test_get_deep_immutable_oplist():
- ops = [rop.ResOperation(rop.rop.INT_ADD, ['a', 'b'])]
+ a = ConstInt(1)
+ b = ConstInt(2)
+ ops = [rop.ResOperation(rop.rop.INT_ADD, [a, b])]
newops = rop.get_deep_immutable_oplist(ops)
py.test.raises(TypeError, "newops.append('foobar')")
py.test.raises(TypeError, "newops[0] = 'foobar'")
py.test.raises(AssertionError, "newops[0].setarg(0, 'd')")
py.test.raises(AssertionError, "newops[0].setdescr('foobar')")
-def test_cast_ops():
- op = rop.ResOperation(rop.rop.INT_SIGNEXT, ['a', ConstInt(1)], 'c')
- assert op.casts_box()
- assert isinstance(op, rop.CastResOp)
- assert op.cast_to() == ('i',1)
- op = rop.ResOperation(rop.rop.CAST_FLOAT_TO_INT, ['a'], 'c')
- assert op.casts_box()
- assert isinstance(op, rop.CastResOp)
+VARI = rop.InputArgInt()
+VARF = rop.InputArgFloat()
+ at py.test.mark.parametrize('opnum,args,kwargs',
+ [ (rop.rop.INT_SIGNEXT, [VARI, ConstInt(2)], {'from': 8, 'to': 2, 'cast_to': ('i', 2) }),
+ (rop.rop.CAST_FLOAT_TO_INT, [VARF], {'from': 8, 'to': 4}),
+ (rop.rop.CAST_SINGLEFLOAT_TO_FLOAT, [VARI], {'from': 4, 'to': 8}),
+ (rop.rop.CAST_FLOAT_TO_SINGLEFLOAT, [VARF], {'from': 8, 'to': 4}),
+ ])
+def test_cast_ops(opnum, args, kwargs):
+ op = rop.ResOperation(opnum, args)
+ assert op.is_typecast()
+ assert op.cast_from_bytesize() == kwargs['from']
+ assert op.cast_to_bytesize() == kwargs['to']
+ if 'cast_to' in kwargs:
+ assert op.cast_to() == kwargs['cast_to']
def test_types():
op = rop.ResOperation(rop.rop.INT_ADD, [ConstInt(0),ConstInt(1)])
More information about the pypy-commit
mailing list