gh-134584: Decref elimination for float ops in the JIT #134588
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.
The key idea is to remove decref of inputs of common operations in the JIT, if they are deemed to be borrowed/using borrowed refcounts. We rely on the base interpreter's static analysis to determine if things are borrowed.
For the float operations, these can't be generated using the cases generator, because they use the
FromDoubleConsumeFloat
things which are notDECREF_INPUT
.For the other list/tuple stuff, or anything that use
DECREF_INPUT
s, we can automatically generate the instruction variants by not emitting the decref at all. However, I left that out of this PR as this is the initial proof of conceptRoughly a 7.5% speedup on nbody just from these optimizations alone!
It's still slower than the normal interpreter on my system, but it's a good start.
I removed the list ops at ad03b1e to make the PR easier to review, we can add them back in later for the speed boost!