codegen optimization: constant expression folding
Description
Follow-up to https://github.com/FuelLabs/sway/pull/7109. Adds support to propagating and folding expressions in the fuel-vm codegen stage.
Checklist
- [ ] I have linked to any relevant issues.
- [ ] 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
- [ ] 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*orNew Featurelabels where relevant. - [ ] I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
- [ ] I have requested a review from the relevant team or maintainers.
CodSpeed Performance Report
Merging #7149 will not alter performance
Comparing dento/asm-gen-opt-2 (a762ce1) with master (a428376)
Summary
✅ 23 untouched benchmarks
With these optimizations enalbed, it's possible to hit a pre-existing bug which causes compiler panic. The should_fail/arith_overflow/u64_mul_overflow test from (cargo run --locked --bin test -- --locked --release) hits this. The multiplication in const_indexing_aggregates_function overflows, and compiler panics:
https://github.com/FuelLabs/sway/blob/5a95c65b61f098897d8e46f25f722f636fe127e0/sway-core/src/asm_generation/fuel/optimizations/const_indexed_aggregates.rs#L118