Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Include/internal/pycore_uop_ids.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2988,6 +2988,24 @@ class Obj:
for _ in range(TIER2_THRESHOLD+1):
obj.attr = EvilAttr(obj.__dict__)

def test_binary_subscr_list_int(self):
def testfunc(n):
l = [1]
x = 0
for _ in range(n):
y = l[0]
x += y
return x

res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertEqual(res, TIER2_THRESHOLD)
self.assertIsNotNone(ex)
uops = get_opnames(ex)

self.assertIn("_BINARY_OP_SUBSCR_LIST_INT", uops)
self.assertNotIn("_POP_TOP", uops)
self.assertNotIn("_POP_TOP_INT", uops)
self.assertIn("_POP_TOP_NOP", uops)

def global_identity(x):
return x
Expand Down
8 changes: 5 additions & 3 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,9 +893,9 @@ dummy_func(
macro(STORE_SLICE) = _SPECIALIZE_STORE_SLICE + _STORE_SLICE;

macro(BINARY_OP_SUBSCR_LIST_INT) =
_GUARD_TOS_INT + _GUARD_NOS_LIST + unused/5 + _BINARY_OP_SUBSCR_LIST_INT;
_GUARD_TOS_INT + _GUARD_NOS_LIST + unused/5 + _BINARY_OP_SUBSCR_LIST_INT + _POP_TOP_INT + POP_TOP;

op(_BINARY_OP_SUBSCR_LIST_INT, (list_st, sub_st -- res)) {
op(_BINARY_OP_SUBSCR_LIST_INT, (list_st, sub_st -- res, ls, ss)) {
PyObject *sub = PyStackRef_AsPyObjectBorrow(sub_st);
PyObject *list = PyStackRef_AsPyObjectBorrow(list_st);

Expand All @@ -918,7 +918,9 @@ dummy_func(
res = PyStackRef_FromPyObjectNew(res_o);
#endif
STAT_INC(BINARY_OP, hit);
DECREF_INPUTS();
ls = list_st;
ss = sub_st;
INPUTS_DEAD();
}

macro(BINARY_OP_SUBSCR_LIST_SLICE) =
Expand Down
26 changes: 9 additions & 17 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 18 additions & 10 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Python/optimizer_bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,12 @@ dummy_func(void) {
}
}

op(_BINARY_OP_SUBSCR_LIST_INT, (list_st, sub_st -- res, ls, ss)) {
res = sym_new_unknown(ctx);
ls = list_st;
ss = sub_st;
}


// END BYTECODES //

Expand Down
16 changes: 13 additions & 3 deletions Python/optimizer_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading