-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
GH-113710: Add a peephole optimization pass. #114487
GH-113710: Add a peephole optimization pass. #114487
Conversation
One other thing to note (that I found a bit surprising) is that 94% of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG except for a stray blank line. I guess the trick to store the code object in the operand of frame push/pop uops is the only thing here that's even remotely clever, which is good.
Python/optimizer_analysis.c
Outdated
static void | ||
peephole_opt(PyCodeObject *co, _PyUOpInstruction *buffer, int buffer_size) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…14487) * Convert _LOAD_CONST to inline versions * Remove PEP 523 checks
…14487) * Convert _LOAD_CONST to inline versions * Remove PEP 523 checks
This PR adds a simple peephole optimizer.
_LOAD_CONST
to the inline versions:_LOAD_CONST_INLINE
and_LOAD_CONST_INLINE_BORROW
.Benchmarking and stats show a ~0.4% speedup (which could just be noise).
There is a ~0.7% reduction in tier 2 instructions executed (from removing the PEP 523 checks).
The change to loading constants will have limited impact on the tier 2 interpreter, but the effect should be more pronounced for the JIT as the operand can be inlined.