gh-130480: Move duplicate LOAD_SMALL_INT optimization from codegen to CFG (#130481)

This commit is contained in:
Yan Yanchii 2025-03-14 22:23:27 +01:00 committed by GitHub
parent 26511993e6
commit 55815a6474
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 146 additions and 116 deletions

View file

@ -282,14 +282,6 @@ codegen_addop_noarg(instr_sequence *seq, int opcode, location loc)
static int
codegen_addop_load_const(compiler *c, location loc, PyObject *o)
{
if (PyLong_CheckExact(o)) {
int overflow;
long val = PyLong_AsLongAndOverflow(o, &overflow);
if (!overflow && _PY_IS_SMALL_INT(val)) {
ADDOP_I(c, loc, LOAD_SMALL_INT, val);
return SUCCESS;
}
}
Py_ssize_t arg = _PyCompile_AddConst(c, o);
if (arg < 0) {
return ERROR;