jit/metainterp/optimizeopt/test/test_optimizeopt.py::TestOptimizeOpt::()::test_loopinvariant_constant_getarrayitem_pure
self = <rpython.jit.metainterp.optimizeopt.test.test_optimizeopt.TestOptimizeOpt object at 0x7f5afb993f90>
def test_loopinvariant_constant_getarrayitem_pure(self):
ops = """
[p0]
p1 = getfield_gc_r(p0, descr=nextdescr)
p2 = getarrayitem_gc_r(p1, 7, descr=gcarraydescr)
call_n(p2, descr=nonwritedescr)
jump(p0)
"""
short = """
[p0]
guard_nonnull(p0) []
guard_is_object(p0) []
guard_subclass(p0, ConstClass(node_vtable)) []
p1 = getfield_gc_r(p0, descr=nextdescr)
guard_nonnull(p1) []
guard_gc_type(p1, ConstInt(gcarraydescr_tid)) []
i1 = arraylen_gc(p1, descr=gcarraydescr)
i2 = int_ge(i1, 8)
guard_true(i2) []
p2 = getarrayitem_gc_r(p1, 7, descr=gcarraydescr)
jump(p1, p2)
"""
expected = """
[p0, p1, p2]
call_n(p2, descr=nonwritedescr)
i3 = arraylen_gc(p1, descr=gcarraydescr) # Should be killed by backend
jump(p0, p1, p2)
"""
> self.optimize_loop(ops, expected, expected_short=short)
jit/metainterp/optimizeopt/test/test_optimizeopt.py:7304:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
jit/metainterp/optimizeopt/test/test_optimizeopt.py:85: in optimize_loop
text_right='expected short preamble')
jit/metainterp/optimizeopt/test/test_util.py:584: in assert_equal
expected.operations, False, remap, text_right)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
oplist1 = [label(r4), guard_nonnull(r4), guard_is_object(r4), guard_subclass(r4, 140028757450576/ci), r5 = getfield_gc_r(r4, descr=FieldDescr(<GcStruct NODE { parent, value, floatval, charval, nexttuple, next }>, 'next')), guard_nonnull(r5), ...]
oplist2 = [label(r12, descr=<rpython.jit.metainterp.optimizeopt.test.test_util.FakeDescr object at 0x7f5afb98d350>), guard_nonnu...cr=FieldDescr(<GcStruct NODE { parent, value, floatval, charval, nexttuple, next }>, 'next')), guard_nonnull(r11), ...]
strict_fail_args = False
remap = {i13 = arraylen_gc(r11, descr=ArrayDescr(<GcArray of * GCREF (gcopaque) >)): i6 = arraylen_gc(r5, descr=ArrayDescr(<Gc...arent, value, floatval, charval, nexttuple, next }>, 'next')), i14 = int_ge(i13, 8/ci): i7 = int_ge(i6, 8/ci), r12: r4}
text_right = 'expected short preamble'
def equaloplists(oplist1, oplist2, strict_fail_args=True, remap={},
text_right=None):
# try to use the full width of the terminal to display the list
# unfortunately, does not work with the default capture method of py.test
# (which is fd), you you need to use either -s or --capture=sys, else you
# get the standard 80 columns width
totwidth = py.io.get_terminal_width()
width = totwidth / 2 - 1
print(' Comparing lists '.center(totwidth, '-'))
text_right = text_right or 'expected'
memo = {}
print('%s| %s' % ('optimized'.center(width), text_right.center(width)))
for op1, op2 in itertools.izip_longest(oplist1, oplist2, fillvalue=''):
if op1:
txt1 = op1.repr(memo)
else:
txt1 = ''
if op2:
txt2 = op2.repr(memo)
else:
txt2 = ''
while txt1 or txt2:
part1 = txt1[:width]
part2 = txt2[:width]
if part1 == part2:
sep = '| '
else:
sep = '<>'
print('%s%s%s' % (part1.ljust(width), sep, part2))
txt1 = txt1[width:]
txt2 = txt2[width:]
print('-' * totwidth)
for i_count, (op1, op2) in enumerate(zip(oplist1, oplist2)):
> assert op1.getopnum() == op2.getopnum()
E assert 93 == 141
E + where 93 = <bound method INT_LE_OP.getopnum of i8 = int_le(i6, 18014398509481984/ci)>()
E + where <bound method INT_LE_OP.getopnum of i8 = int_le(i6, 18014398509481984/ci)> = i8 = int_le(i6, 18014398509481984/ci).getopnum
E + and 141 = <bound method GETARRAYITEM_GC_R_OP.getopnum of r10 = getarrayitem_gc_r(r11, 7/ci, descr=ArrayDescr(<GcArray of * GCREF (gcopaque) >))>()
E + where <bound method GETARRAYITEM_GC_R_OP.getopnum of r10 = getarrayitem_gc_r(r11, 7/ci, descr=ArrayDescr(<GcArray of * GCREF (gcopaque) >))> = r10 = getarrayitem_gc_r(r11, 7/ci, descr=ArrayDescr(<GcArray of * GCREF (gcopaque) >)).getopnum
jit/metainterp/optimizeopt/util.py:166: AssertionError
---------- Captured stderr setup ----------
[jitcodewriter] compute_bitstrings:
[jitcodewriter] 40 effectinfos:
[jitcodewriter] 2 descrs for arrays
[jitcodewriter] 4 descrs for fields
[jitcodewriter] 0 descrs for interiorfields
[jitcodewriter] -> 5 bitstrings, mean length 0.8, max length 1
---------- Captured stdout call ----------
Preamble:
label(r0)
r1 = getfield_gc_r(r0, descr=FieldDescr(<GcStruct NODE { parent, value, floatval, charval, nexttuple, next }>, 'next'))
r2 = getarrayitem_gc_r(r1, 7/ci, descr=ArrayDescr(<GcArray of * GCREF (gcopaque) >))
call_n(r2, descr=CallDescr(<Signed>, (<Signed>,), <EffectInfo 0x7f5afc4ba3d0: EF=5>))
label(r0, r1, r2, descr=<rpython.jit.metainterp.history.TargetToken object at 0x7f5afb98d490>)
Loop:
label(r0, r1, r2, descr=<rpython.jit.metainterp.history.TargetToken object at 0x7f5afb98d490>)
call_n(r2, descr=CallDescr(<Signed>, (<Signed>,), <EffectInfo 0x7f5afc4ba3d0: EF=5>))
i3 = arraylen_gc(r1, descr=ArrayDescr(<GcArray of * GCREF (gcopaque) >))
jump(r0, r1, r2, descr=<rpython.jit.metainterp.history.TargetToken object at 0x7f5afb98d490>)
Short Preamble:
label(r4)
guard_nonnull(r4)
guard_is_object(r4)
guard_subclass(r4, 140028757450576/ci)
r5 = getfield_gc_r(r4, descr=FieldDescr(<GcStruct NODE { parent, value, floatval, charval, nexttuple, next }>, 'next'))
guard_nonnull(r5)
guard_gc_type(r5, <rpython.jit.backend.llgraph.runner.TypeIDSymbolic object at 0x7f5afb99d110>/ci)
i6 = arraylen_gc(r5, descr=ArrayDescr(<GcArray of * GCREF (gcopaque) >))
i7 = int_ge(i6, 8/ci)
guard_true(i7)
i8 = int_le(i6, 18014398509481984/ci)
guard_true(i8)
r9 = getarrayitem_gc_r(r5, 7/ci, descr=ArrayDescr(<GcArray of * GCREF (gcopaque) >))
jump(r5, r9)
------------------------------- Comparing lists --------------------------------
optimized | expected
label(r0, r1, r2, descr=<rpython.jit.me<>label(r3, r4, r5, descr=<rpython.jit.me
tainterp.history.TargetToken object at <>tainterp.optimizeopt.test.test_util.Fak
0x7f5afb98d490>) <>eDescr object at 0x7f5afb68bc50>)
call_n(r2, descr=CallDescr(<Signed>, (<<>call_n(r5, descr=CallDescr(<Signed>, (<
Signed>,), <EffectInfo 0x7f5afc4ba3d0: | Signed>,), <EffectInfo 0x7f5afc4ba3d0:
EF=5>)) | EF=5>))
i6 = arraylen_gc(r1, descr=ArrayDescr(<<>i7 = arraylen_gc(r4, descr=ArrayDescr(<
GcArray of * GCREF (gcopaque) >)) | GcArray of * GCREF (gcopaque) >))
jump(r0, r1, r2, descr=<rpython.jit.met<>jump(r3, r4, r5)
ainterp.history.TargetToken object at 0<>
x7f5afb98d490>) <>
--------------------------------------------------------------------------------
------------------------------- Comparing lists --------------------------------
optimized | expected short preamble
label(r0) <>label(r1, descr=<rpython.jit.metainterp
<>.optimizeopt.test.test_util.FakeDescr o
<>bject at 0x7f5afb98d350>)
guard_nonnull(r0) <>guard_nonnull(r1)
guard_is_object(r0) <>guard_is_object(r1)
guard_subclass(r0, 140028757450576/ci) <>guard_subclass(r1, 140028757450576/ci)
r2 = getfield_gc_r(r0, descr=FieldDescr<>r3 = getfield_gc_r(r1, descr=FieldDescr
(<GcStruct NODE { parent, value, floatv| (<GcStruct NODE { parent, value, floatv
al, charval, nexttuple, next }>, 'next'| al, charval, nexttuple, next }>, 'next'
)) | ))
guard_nonnull(r2) <>guard_nonnull(r3)
guard_gc_type(r2, <rpython.jit.backend.<>guard_gc_type(r3, <rpython.jit.backend.
llgraph.runner.TypeIDSymbolic object at| llgraph.runner.TypeIDSymbolic object at
0x7f5afb99d110>/ci) <> 0x7f5afc492c90>/ci)
i4 = arraylen_gc(r2, descr=ArrayDescr(<<>i5 = arraylen_gc(r3, descr=ArrayDescr(<
GcArray of * GCREF (gcopaque) >)) | GcArray of * GCREF (gcopaque) >))
i6 = int_ge(i4, 8/ci) <>i7 = int_ge(i5, 8/ci)
guard_true(i6) <>guard_true(i7)
i8 = int_le(i4, 18014398509481984/ci) <>r9 = getarrayitem_gc_r(r3, 7/ci, descr=
<>ArrayDescr(<GcArray of * GCREF (gcopaqu
<>e) >))
guard_true(i8) <>jump(r3, r9)
r10 = getarrayitem_gc_r(r2, 7/ci, descr<>
=ArrayDescr(<GcArray of * GCREF (gcopaq<>
ue) >)) <>
jump(r2, r10) <>
--------------------------------------------------------------------------------
---------- Captured stderr call ----------
[c607242030b4980] {jit-optimize
[c607242030c4d00] {jit-log-intbounds
[p0]
p1 = getfield_gc_r(p0, descr=FieldDescr(<GcStruct NODE { parent, value, floatval, charval, nexttuple, next }>, 'next'))
p3 = getarrayitem_gc_r(p1, 7, descr=ArrayDescr(<GcArray of * GCREF (gcopaque) >))
call_n(p3, descr=CallDescr(<Signed>, (<Signed>,), <EffectInfo 0x7f5afc4ba3d0: EF=5>))
[c60724203150780] jit-log-intbounds}
[c60724203184980] {jit-log-exported-state
[r0]
HeapOp(r1 = getfield_gc_r(r0, descr=FieldDescr(<GcStruct NODE { parent, value, floatval, charval, nexttuple, next }>, 'next')), r2 = getfield_gc_r(r0, descr=FieldDescr(<GcStruct NODE { parent, value, floatval, charval, nexttuple, next }>, 'next')))
INP(r0)
HeapOp(r3 = getarrayitem_gc_r(r1, 7/ci, descr=ArrayDescr(<GcArray of * GCREF (gcopaque) >)), r4 = getarrayitem_gc_r(r1, 7/ci, descr=ArrayDescr(<GcArray of * GCREF (gcopaque) >)))
[c60724203197600] jit-log-exported-state}
[c6072420319cc00] jit-optimize}
[c607242031acc00] {jit-optimize
[c607242031e7b80] {jit-log-intbounds
[p0]
call_n(p1, descr=CallDescr(<Signed>, (<Signed>,), <EffectInfo 0x7f5afc4ba3d0: EF=5>))
[c6072420322ad80] jit-log-intbounds}
i3 = arraylen_gc(p2, descr=ArrayDescr(<GcArray of * GCREF (gcopaque) >))
jump(p4, p2, p1, descr=TargetToken(140028744881296))
[c607242032abe00] jit-optimize}
builder: rpython-linux-x86-64 build #922+
test: jit/metainterp/optimizeopt/test/test_optimizeopt.py::TestOptimizeOpt::()::test_loopinvariant_constant_getarrayitem_pure