and _POP_TOP_LOAD_CONST_INLINE_BORROW should then be completely removed from the JIT uops and bytecodes.c. This will allow us to de-duplicate and refactor the code greatly, while making the existing optimizations also more effective as we don't have to do as much repeated work.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
@NekoAsakura I don't think we assign things here to non-coreteam, but feel free to comment which ops you are taking op (this is a big issue), and I'll make sure to deconflict. Thanks a lot!
I've noticed that some of the optimizer functions are gaining boolean parameters for whether to pop, or insert. To read the code requires constant reference to the function being called.
For future PRs consider using prefix and/or postfix instructions as arguments, to improve clarity.
optimize_thing(POP_TOP, value, NOP) is easier to follow than optimize_thing(value, true, false)
Activity
Fidget-Spinner commented on Apr 7, 2026
@NekoAsakura would you like to work on this?
NekoAsakura commented on Apr 7, 2026
Of course! Pls assign it to me <3
Fidget-Spinner commented on Apr 7, 2026
@NekoAsakura I don't think we assign things here to non-coreteam, but feel free to comment which ops you are taking op (this is a big issue), and I'll make sure to deconflict. Thanks a lot!
NekoAsakura commented on Apr 7, 2026
Uh, I just meant an oral assignment, similar to what you did in #145866 (comment), but no worries!
I've had a look through composite uops. These are some straightforward POP + LOAD_CONST fusions that can be cleanly decomposed:
Happy to take the first three in one PR and leave the rest for anyone else who fancies having a go. Sound alright?
Fidget-Spinner commented on Apr 7, 2026
Sounds good, thanks for taking these up!
pythongh-148211: decompose `_POP_TOP_LOAD_CONST_INLINE(_BORROW)` in JIT
NekoAsakura commented on Apr 7, 2026
A bit more:
Merge branch 'main' into pythongh-148211/decompose-pop-top
Merge branch 'main' into pythongh-148211/decompose-pop-top
pythongh-148211: decompose `_POP_TOP_LOAD_CONST_INLINE(_BORROW)` in JIT
gh-148211: decompose `_POP_TOP_LOAD_CONST_INLINE(_BORROW)` in JIT (GH…
markshannon commented on Apr 8, 2026
I've noticed that some of the optimizer functions are gaining boolean parameters for whether to pop, or insert. To read the code requires constant reference to the function being called.
For future PRs consider using prefix and/or postfix instructions as arguments, to improve clarity.
optimize_thing(POP_TOP, value, NOP) is easier to follow than optimize_thing(value, true, false)
20 remaining items
gh-148211: decompose `[_POP_TWO/_INSERT_2]_LOAD_CONST_INLINE_BORROW` …
pythongh-148211: decompose / in JIT
pythongh-148211: decompose `_POP_TWO/_POP_CALL(_ONE/_TWO)` in JIT
gh-148211: decompose `_POP_TWO/_POP_CALL(_ONE/_TWO)` in JIT (GH-148377)
Fidget-Spinner commented on Apr 11, 2026
Thanks to a lot of effort from @NekoAsakura , this is done. Thanks a lot for cleaning up the JIT!
pythongh-148211: decompose `_SHUFFLE_3_LOAD_CONST_INLINE_BORROW` in JIT
Merge branch 'main' into pythongh-148211/decompose-shuffle-3
pythongh-148211: decompose `_POP_TOP_LOAD_CONST_INLINE(_BORROW)` in J…
pythongh-148211: refactor bool to explicit uops in JIT (pythonGH-148258)
pythongh-148211: decompose `_INSERT_1_LOAD_CONST_INLINE(_BORROW)` in …
pythongh-148211: decompose `[_POP_CALL_X/_SHUFFLE_2]_LOAD_CONST_INLIN…
pythongh-148211: decompose `[_POP_TWO/_INSERT_2]_LOAD_CONST_INLINE_BO…
pythongh-148211: decompose `_POP_TWO/_POP_CALL(_ONE/_TWO)` in JIT (py…
gh-148211: decompose `_SHUFFLE_3_LOAD_CONST_INLINE_BORROW` in JIT (GH…