sway icon indicating copy to clipboard operation
sway copied to clipboard

codegen optimization: constant expression folding

Open Dentosal opened this issue 7 months ago • 2 comments

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).
  • [ ] 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.
  • [ ] 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.

Dentosal avatar May 05 '25 08:05 Dentosal

CodSpeed Performance Report

Merging #7149 will not alter performance

Comparing dento/asm-gen-opt-2 (a762ce1) with master (a428376)

Summary

✅ 23 untouched benchmarks

codspeed-hq[bot] avatar May 05 '25 08:05 codspeed-hq[bot]

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

Dentosal avatar May 21 '25 10:05 Dentosal