8000 GH-130415: Optimize constant comparison in JIT builds by savannahostrowski · Pull Request #131489 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-130415: Optimize constant comparison in JIT builds #131489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 21, 2025
Prev Previous commit
Next Next commit
Compute result and use rich compare
  • Loading branch information
savannahostrowski committed Mar 19, 2025
commit fee3937b9b1e2e1cc06656f368c0ff2083ddf185
10 changes: 9 additions & 1 deletion Python/optimizer_bytecodes.c
785E
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,17 @@ dummy_func(void) {
{
assert(PyLong_CheckExact(sym_get_const(ctx, left)));
assert(PyLong_CheckExact(sym_get_const(ctx, right)));
PyObject *tmp = PyObject_RichCompare(sym_get_const(ctx, left),
sym_get_const(ctx, right),
oparg >> 5);
if (tmp == NULL) {
goto error;
}
res = sym_new_const(ctx, tmp);
Py_DECREF(tmp);

if (_Py_IsImmortal(res)) {
REPLACE_OP(this_instr, _POP_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)true);
REPLACE_OP(this_instr, _POP_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)tmp);
}
else {
res = sym_new_type(ctx, &PyBool_Type);
Expand Down
21 changes: 17 additions & 4 deletions Python/optimizer_cases.c.h

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

0