Latest Results
Optimise `pshl` (#7561)
## Description
Change the order of register allocation... instead of starting from
"lower" registers... it starts from higher registers... that means that
for functions with very few registers, there is no need to save them
with `pshl`. Example:
```sway
#[inline(never)]
fn leaf_fn_6(a: u64, b: u64, c: u64, d: u64, e: u64, f: u64) -> u64 {
a + b + c + d + e + f
}
```
Before:
```asm
pshl i1 ; [fn init: leaf_fn_6_2]: push used low registers 16..40
pshh i524288 ; [fn init: leaf_fn_6_2]: push used high registers 40..64
add $r0 $$arg0 $$arg1
add $r0 $r0 $$arg2
add $r0 $r0 $$arg3
add $r0 $r0 $$arg4
add $r0 $r0 $$arg5
move $$retv $r0 ; [fn end: leaf_fn_6_2] set return value
poph i524288 ; [fn end: leaf_fn_6_2]: restore used high registers 40..64
popl i1 ; [fn end: leaf_fn_6_2]: restore used low registers 16..40
jal $zero $$reta i0 ; [fn end: leaf_fn_6_2] return from call
```
After
```asm
pshh i528384 ; [fn init: leaf_fn_6_2]: push used high registers 40..64
add $r0 $$arg0 $$arg1
add $r0 $r0 $$arg2
add $r0 $r0 $$arg3
add $r0 $r0 $$arg4
add $r0 $r0 $$arg5
move $$retv $r0 ; [fn end: leaf_fn_6_2] set return value
poph i528384 ; [fn end: leaf_fn_6_2]: restore used high registers 40..64
jal $zero $$reta i0 ; [fn end: leaf_fn_6_2] return from call
```
Please notice that `pshl i1` and `popl i1` were removed.
## Checklist
- [ ] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers. Active Branches
0%
0%
-18%
© 2026 CodSpeed Technology