Message411697
...as discussed in https://github.com/faster-cpython/ideas/discussions/228.
We can dramatically simplify our stack manipulations by getting rid of the `DUP_TOP*` and `ROT_*` families of instructions:
- Replace `DUP_TOP` with `COPY(1)`.
- Replace `DUP_TOP_TWO` with `COPY(2), COPY(2)`.
- Introduce a new `SWAP` instruction.
- Replace `ROT_TWO` with `SWAP(2)`.
- Replace `ROT_THREE` with `SWAP(3), SWAP(2)`.
- Remove `ROT_FOUR`.
- Replace `ROT_N(n)` with `SWAP(n), SWAP(n - 1), ..., SWAP(2)`.
It then becomes much simpler for the peephole optimizer to reason about code sequences involving these instructions (for example, it's pretty straightforward to truly *optimize* an arbitrary sequence of swaps). |
|
Date |
User |
Action |
Args |
2022-01-26 01:39:59 | brandtbucher | set | recipients:
+ brandtbucher, Mark.Shannon |
2022-01-26 01:39:59 | brandtbucher | set | messageid: <1643161199.78.0.253250267538.issue46528@roundup.psfhosted.org> |
2022-01-26 01:39:59 | brandtbucher | link | issue46528 messages |
2022-01-26 01:39:59 | brandtbucher | create | |
|