https://github.com/python/cpython/commit/79d81f7cba236e2cbdfa95d0de0a75ba9716ed32
commit: 79d81f7cba236e2cbdfa95d0de0a75ba9716ed32
branch: main
author: Noam Cohen <[email protected]>
committer: Fidget-Spinner <[email protected]>
date: 2025-05-28T02:30:17+08:00
summary:
gh-131798: Optimize `_ITER_CHECK_TUPLE` (GH-134803)
files:
A
Misc/NEWS.d/next/Core_and_Builtins/2025-05-27-20-21-34.gh-issue-131798.b32zkl.rst
M Python/optimizer_bytecodes.c
M Python/optimizer_cases.c.h
diff --git
a/Misc/NEWS.d/next/Core_and_Builtins/2025-05-27-20-21-34.gh-issue-131798.b32zkl.rst
b/Misc/NEWS.d/next/Core_and_Builtins/2025-05-27-20-21-34.gh-issue-131798.b32zkl.rst
new file mode 100644
index 00000000000000..ed4b31bd7bedce
--- /dev/null
+++
b/Misc/NEWS.d/next/Core_and_Builtins/2025-05-27-20-21-34.gh-issue-131798.b32zkl.rst
@@ -0,0 +1 @@
+Allow the JIT to remove unnecessary ``_ITER_CHECK_TUPLE`` ops.
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c
index 34250fd4385d34..e1209209660f92 100644
--- a/Python/optimizer_bytecodes.c
+++ b/Python/optimizer_bytecodes.c
@@ -914,6 +914,13 @@ dummy_func(void) {
}
}
+ op(_ITER_CHECK_TUPLE, (iter, null_or_index -- iter, null_or_index)) {
+ if (sym_matches_type(iter, &PyTuple_Type)) {
+ REPLACE_OP(this_instr, _NOP, 0, 0);
+ }
+ sym_set_type(iter, &PyTuple_Type);
+ }
+
op(_ITER_NEXT_RANGE, (iter, null_or_index -- iter, null_or_index, next)) {
next = sym_new_type(ctx, &PyLong_Type);
}
diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h
index bbd45067103679..db86edcc7859b5 100644
--- a/Python/optimizer_cases.c.h
+++ b/Python/optimizer_cases.c.h
@@ -1615,6 +1615,12 @@
}
case _ITER_CHECK_TUPLE: {
+ JitOptSymbol *iter;
+ iter = stack_pointer[-2];
+ if (sym_matches_type(iter, &PyTuple_Type)) {
+ REPLACE_OP(this_instr, _NOP, 0, 0);
+ }
+ sym_set_type(iter, &PyTuple_Type);
break;
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]