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-131798: Small improvements to remove_unneeded_uops #134554

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 1 commit into from
May 23, 2025
Merged
Changes from all commits
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
3 changes: 2 additions & 1 deletion 3 Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ const uint16_t op_without_push[MAX_UOP_ID + 1] = {
const bool op_skip[MAX_UOP_ID + 1] = {
[_NOP] = true,
[_CHECK_VALIDITY] = true,
[_CHECK_PERIODIC] = true,
[_SET_IP] = true,
};

Expand Down Expand Up @@ -617,7 +618,7 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
while (op_skip[last->opcode]) {
last--;
}
if (op_without_push[last->opcode]) {
if (op_without_push[last->opcode] && op_without_pop[opcode]) {
last->opcode = op_without_push[last->opcode];
opcode = buffer[pc].opcode = op_without_pop[opcode];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we are here, we know that op_without_pop[opcode] || op_without_pop_null[opcode] is true. But we should also make sure that op_without_pop[opcode] itself is true, otherwise it is possible to accidentally write 0 as the opcode.

if (op_without_pop[last->opcode]) {
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.