gh-114083: apply optimization of LOAD_CONST instructions to the whole CFG before optimize_basic_block.#114408
Merged
iritkatriel merged 7 commits intopython:mainfrom Jan 22, 2024
Merged
Conversation
…e CFG before optimize_basic_block.
markshannon
requested changes
Jan 22, 2024
Member
markshannon
left a comment
There was a problem hiding this comment.
Looks good.
There are a couple of things that could do with minor clarifications.
Python/flowgraph.c
Outdated
|
|
||
| static int | ||
| optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts) | ||
| basicblock_fold_load_const(PyObject *const_cache, basicblock *bb, PyObject *consts) |
Member
There was a problem hiding this comment.
"fold" has many meanings in CS.
Maybe fold_jumps?
Member
Author
There was a problem hiding this comment.
It's not only jumps. This function also fold LOAD_CONST + POP_TOP/RETURN_VALUE/TO_BOOL etc
Member
Author
There was a problem hiding this comment.
I'll call it optimize_load_const instead of fold_load_const.
|
When you're done making the requested changes, leave the comment: |
AlexWaygood
reviewed
Jan 22, 2024
Misc/NEWS.d/next/Core and Builtins/2024-01-22-09-48-58.gh-issue-114083.hf1-ku.rst
Outdated
Show resolved
Hide resolved
…e-114083.hf1-ku.rst
Member
Author
|
I have made the requested changes; please review again. |
markshannon
approved these changes
Jan 22, 2024
aisk
pushed a commit
to aisk/cpython
that referenced
this pull request
Feb 11, 2024
… whole CFG before optimize_basic_block. (python#114408)
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this pull request
Sep 2, 2024
… whole CFG before optimize_basic_block. (python#114408)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #114083.
Currently, folding LOAD_CONST + TO_BOOL + CONDITIONAL_JUMP into an unconditional JUMP occurs in the same pass as jump threading. For this code:
We try to thread the jump in block1 before we collapse block2 into an unconditional jump, so threading is not applied, and we can end up with a redundant jump.
This PR splits the folding of LOAD_CONST + the following instruction into a separate pass, before the pass that applies jump threading.