| name | constant-folding |
| description | Implement issue |
Constant Folding
Use this skill to execute issue #140 with small, correctness-first compiler changes.
Workflow
- Implement a dedicated function pass that folds compile-time constant expressions.
- Reuse existing fold semantics helper (
try_fold) to avoid divergent rules.
- Integrate pass into optimization presets (
-O1, -O2, -O3).
- Add regression tests for both folded (
2 + 2) and non-folded (value-dependent) cases.
- Run targeted and full test suites.
- Review PR, post review findings, and merge once checks are green.
Minimum validation
cargo +stable test -p llvm-transforms
cargo +stable test -q
Notes
- Preserve behavior on undefined/edge cases (e.g., division by zero stays unfolder).
- Keep pass ordering explicit in
pipeline.rs to satisfy roadmap traceability.