Replace scratch register with XOR swap
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reviewing the MachineEnv scratch-register requirement and the linked regalloc2 overview and follow-on article. Determine whether XOR swaps are valid for the relevant register classes and ISAs, and whether they preserve the allocator's required behavior. Done means reaching a concrete, documented decision about whether this should replace scratch-register swaps.
Written by the indexing model from the issue text.
Description
I'm getting up to snuff on compiler backend details for a personal project and the regalloc2 overview and the follow on article have been great.
I'm not going to pretend to completely understand the details here, but the MachineEnv requires a scratch register for what I gather is typically swaps, symbolically like this.
let x = 4;
let y = 5;
let swap = x;
x = y;
y = swap;
However there is a way to swap two values without introducing a third variable/register which is via an XOR swap:
x = y ^ x;
y = x ^ y;
x = y ^ x;
You shouldn't do this in high level code but should be fine in machine code of course. If an ISA allows integer operations to be applied to float registers then this can be used for both classes.
I'm nearly certain you know of this already, but I wanted to get it out there for the off chance, and if nothing else get details on why it wouldn't work.
- Dominant language
- Rust
- Stars
- 266
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
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.
More from bytecodealliance/regalloc2
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
bytecodealliance/regalloc2#265 · 7 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
bytecodealliance/regalloc2#247 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
bytecodealliance/regalloc2#222 · 4 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
bytecodealliance/regalloc2#194 · 7 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
bytecodealliance/regalloc2#191 · 3 comments ·
All issues in bytecodealliance/regalloc2
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
issue
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
web-infra-dev/rspack#15847 ·