Add effective peephole optimizer for uop traces.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Feature or enhancement
Currently we lack an effective peephole optimizer for uops traces.
We do some ad-hoc removal of LOAD/POP pairs, but many enhancements are missed.
For example, this silly program:
def add(a, b):
return a + b
def loop(n=100_000):
t = 0
for _ in range(n):
t += add(1,2)
if __name__ == "__main__":
loop()
generates this trace:
which contains the sequence:
_LOAD_FAST_BORROW 0
_LOAD_FAST_BORROW_1
_LOAD_CONST_INLINE_BORROW K
_RROT_3
_POP_TOP_NOP
_POP_TOP_NOP
which should be reduced to
_LOAD_CONST_INLINE_BORROW K
Linked PRs
- gh-153035
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the uop trace optimizer and the existing ad-hoc LOAD/POP removal, then reproduce the supplied add/loop trace. Compare the current sequence with the proposed reduced sequence; done means the optimizer handles this case and has coverage for the transformation. Review linked PR gh-153035 before starting, since work is already associated with it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100