GH-135379: Support limited scalar replacement for replicated uops in the JIT code generator.#135563
Conversation
…nerator. Use it to support efficient specializations of COPY and SWAP in the JIT.
|
scalarize works too. |
| ] + items[index+1:] | ||
|
|
||
| def scalarize_stack(stack: StackEffect, oparg: int) -> StackEffect: | ||
| # Only scalarize if no more than one input or output is array |
There was a problem hiding this comment.
This comment doesn't seem to belong to this code segment?
There was a problem hiding this comment.
Yes, I refactored the code but didn't move the comment.
|
This is scalar replacement. We are replacing a composite object (an array in this case) with a set of scalar values. In the JVM, that means breaking down an object into its parts. The JVM version is a lot more complex and powerful, but it is doing the same thing, and the motivation is the same: register allocation. |
It's somewhat confusing because it's scalar replacement in the JIT, but not in the default interpreter. Though you subtly implied it with the "uops". |
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
There was a problem hiding this comment.
This entire part is somewhat confusing, but I'll let it slide since there's a comment up top :).
…ps in the JIT code generator. (pythonGH-135563) * Use it to support efficient specializations of COPY and SWAP in the JIT.
…ps in the JIT code generator. (pythonGH-135563) * Use it to support efficient specializations of COPY and SWAP in the JIT.
…ps in the JIT code generator. (pythonGH-135563) * Use it to support efficient specializations of COPY and SWAP in the JIT.
…ps in the JIT code generator. (pythonGH-135563) * Use it to support efficient specializations of COPY and SWAP in the JIT.

This PR does three things:
replicateto support ranges starting from values other than zeroCOPYandSWAPto take advantage of that.With TOS caching this should allow
COPYandSWAPto be implemented as register-to-register moves.