gh-131798: Optimize _ITER_CHECK_TUPLE (GH-134803)

This commit is contained in:
Noam Cohen 2025-05-27 21:30:17 +03:00 committed by GitHub
parent ac539e7e0d
commit 79d81f7cba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 0 deletions

View file

@ -0,0 +1 @@
Allow the JIT to remove unnecessary ``_ITER_CHECK_TUPLE`` ops.

View file

@ -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);
}

View file

@ -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;
}