gh-126835: Move constant subscript folding to CFG (#129568)

Move folding of constant subscription from AST optimizer to CFG.

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
Yan Yanchii 2025-02-04 09:10:55 +01:00 committed by GitHub
parent bb5c6875d6
commit 0664c1af9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 138 additions and 31 deletions

View file

@ -284,7 +284,7 @@ codegen_addop_load_const(compiler *c, location loc, PyObject *o)
if (PyLong_CheckExact(o)) {
int overflow;
long val = PyLong_AsLongAndOverflow(o, &overflow);
if (!overflow && val >= 0 && val < 256 && val < _PY_NSMALLPOSINTS) {
if (!overflow && _PY_IS_SMALL_INT(val)) {
ADDOP_I(c, loc, LOAD_SMALL_INT, val);
return SUCCESS;
}