Refactor optimizer with aggressive collapsing

The optimizer has been refactored to separate its phases and introduce
more aggressive collapsing capabilities.

Phase 2 (Cracking) now focuses on stateless transformations, making it
easier to reason about and potentially parallelize.

Phase 2.5 (Aggressive Collapsing) has been introduced, enabling
optimizations like:
- Beta-reduction for lambda literals.
- Cracking and inlining for constant closures.
- Folding intrinsics for constant arithmetic.
- Short-circuiting conditional expressions.

These changes aim to improve performance by reducing redundant
computations and code bloat. The maximum number of optimization passes
has also been increased to 5 to allow for more complex transformations.
This commit is contained in:
Michael Schimmel
2026-02-21 19:42:09 +01:00
parent 0bbe35eeec
commit 56b8e8389b
5 changed files with 434 additions and 202 deletions
+5 -3
View File
@@ -82,9 +82,11 @@ mod tests {
#[test]
fn test_examples() {
let results = crate::utils::tester::run_functional_tests();
for res in results {
assert!(res.success, "Example {} failed: {}", res.name, res.message);
for level in 0..=2 {
let results = crate::utils::tester::run_functional_tests_with_level(level);
for res in results {
assert!(res.success, "Example {} failed at level {}: {}", res.name, level, res.message);
}
}
}