-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-146306: Optimize float operations by mutating uniquely-referenced operands in place (JIT only) #146307
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
Fidget-Spinner
merged 12 commits into
python:main
from
eendebakpt:jit_float_inplace_rebased
Mar 24, 2026
Merged
gh-146306: Optimize float operations by mutating uniquely-referenced operands in place (JIT only) #146307
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
42d12b7
gh-146306: Optimize float arithmetic in JIT by mutating uniquely-refe…
eendebakpt 637803c
Fix JIT stencil compilation on i686-pc-windows-msvc
eendebakpt 8559fb8
Fix i686 Windows JIT: use x87 FPU instead of SSE for stencils
eendebakpt 7bfdedb
Update Python/bytecodes.c
eendebakpt c8f860f
Use sym_new_null for consumed operand slots in inplace float ops
eendebakpt fbedeb3
Revert unrelated bytecodes.c comment/whitespace changes
eendebakpt 1efd764
Merge branch 'main' into jit_float_inplace_rebased
eendebakpt 78c11e1
regenerate
eendebakpt 8af7b51
handle case there operand is set to null
eendebakpt 7d63316
reduce duplication in new opcodes
eendebakpt c61b9af
review comments
eendebakpt 4ff36c1
cleanup unary opcode
eendebakpt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use sym_new_null for consumed operand slots in inplace float ops
The inplace ops set l or r to PyStackRef_NULL at runtime, so the optimizer should model this as sym_new_null(ctx) rather than PyJitRef_Borrow(). Both produce _POP_TOP_NOP but sym_new_null correctly matches the runtime semantics. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Loading branch information
commit c8f860f521a0e9392a97c0d03cacb7c5135e8857
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
This op and its variants all share a lot of common code.
Could you factor out the code into a macro to perform the inplace operation?
Like:
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.
Normal C macros are not allowed in the bytecodes.c opcodes (they are not expanded). I have not yet found a way to refactor this nicely.
We could add a new macro to the DSL (like
INPUTS_DEAD) for this, but it feels a bit odd to add something to the DSL for this particular case.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.
They are. You just need to define them in
ceval_macros.h. Would you like me to do this, or would you like to do it?