Narrow integer load/store operations
Spec PR: https://github.com/FuelLabs/fuel-specs/pull/628
Adds LQW LHW SQW SHW instructions to store and load quarter and half words efficiently. They follow the same conventions as their pre-existiing counterparts LB LW SB SW. The new instructions have same cost as their full-word counterparts.
Checklist
- [x] Breaking changes are clearly marked as such in the PR description and changelog: None!
- [x] New behavior is reflected in tests
- [ ] If performance characteristic of an instruction change, update gas costs as well or make a follow-up PR for that: using gas costs of existing instructions as a baseline
- [x] The specification matches the implemented behavior: https://github.com/FuelLabs/fuel-specs/pull/628
Before requesting review
- [x] I have reviewed the code myself
- [ ] I have created follow-up issues caused by this PR and linked them here
@Dentosal Could you post benchmark results please? Just to show the impact of the change
This isn't really done for performance or code size reasons, but to help the compiler team with implementing the trickier details of stdlib implementation. I have a modified sway compiler in a way that shows minimum impact, but we can get way more out of these if we do advanced packing of the data section as well. (i.e. substring search, and ordering it in a way that produces the best substrings). Also this should make some optimizations with store ops possible, but those haven't been explored yet. I've benchmarked with the minimum impact version here:
The benchmark results for mira-v1-core (release build):
latest sway 8e162c966 |
after changes | reduction |
|---|---|---|
| 89.384 KB | 88.764 KB | 0.7% |
From my side the only blocker is adding proper support for the WASM constructors of these new instructions.