Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-126835: Avoid creating unnecessary tuple when looking for constant sequence during constant folding #131054

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 7 commits into from
Mar 12, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename get_const_sequence_instructions
  • Loading branch information
WolframAlph committed Mar 10, 2025
commit 64eb38dc6b622c5f67cf58c471d3d134e937352b
10 changes: 5 additions & 5 deletions 10 Python/flowgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ add_const(PyObject *newconst, PyObject *consts, PyObject *const_cache)
Returns boolean indicating whether succeeded to collect requested number of instructions.
iritkatriel marked this conversation as resolved.
Show resolved Hide resolved
*/
static bool
get_const_sequence_instructions(basicblock *bb, int start, cfg_instr **seq, int size)
get_const_instr_sequence(basicblock *bb, int start, cfg_instr **seq, int size)
WolframAlph marked this conversation as resolved.
Show resolved Hide resolved
{
assert(start < bb->b_iused);
assert(size >= 0);
Expand Down Expand Up @@ -1426,7 +1426,7 @@ fold_tuple_of_constants(basicblock *bb, int i, PyObject *consts, PyObject *const
}

cfg_instr *seq[STACK_USE_GUIDELINE];
if (!get_const_sequence_instructions(bb, i-1, seq, seq_size)) {
if (!get_const_instr_sequence(bb, i-1, seq, seq_size)) {
/* not a const sequence */
return SUCCESS;
}
Expand Down Expand Up @@ -1482,7 +1482,7 @@ optimize_lists_and_sets(basicblock *bb, int i, int nextop,
}

cfg_instr *seq[STACK_USE_GUIDELINE];
if (!get_const_sequence_instructions(bb, i-1, seq, seq_size)) { /* not a const sequence */
if (!get_const_instr_sequence(bb, i-1, seq, seq_size)) { /* not a const sequence */
if (contains_or_iter && instr->i_opcode == BUILD_LIST) {
/* iterate over a tuple instead of list */
INSTR_SET_OP1(instr, BUILD_TUPLE, instr->i_oparg);
Expand Down Expand Up @@ -1722,7 +1722,7 @@ fold_const_binop(basicblock *bb, int i, PyObject *consts, PyObject *const_cache)
assert(binop->i_opcode == BINARY_OP);

cfg_instr *seq[BINOP_OPERAND_COUNT];
if (!get_const_sequence_instructions(bb, i-1, seq, BINOP_OPERAND_COUNT)) {
if (!get_const_instr_sequence(bb, i-1, seq, BINOP_OPERAND_COUNT)) {
/* not a const sequence */
return SUCCESS;
}
Expand Down Expand Up @@ -1804,7 +1804,7 @@ fold_const_unaryop(basicblock *bb, int i, PyObject *consts, PyObject *const_cach
cfg_instr *unaryop = &bb->b_instr[i];

cfg_instr *instr;
if (!get_const_sequence_instructions(bb, i - 1, &instr, UNARYOP_OPERAND_COUNT)) {
if (!get_const_instr_sequence(bb, i - 1, &instr, UNARYOP_OPERAND_COUNT)) {
/* not a const */
return SUCCESS;
}
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.