Commit 6d3a86ba
6d3a86bac528Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 2 files · +1 added · ~1 modified
Description
feat: bigint auto-promotion for fibonacci-style addition
Extend scan_bigint_in_loop to detect unbounded addition patterns like fibonacci: c = a + b where both operands are variables that reach c via the assignment chain. This triggers bigint promotion for all three variables.
Key: add_is_unbounded requires BOTH left and right operands to be reachable from the target (rejects i = i + 1 where RHS is a constant — linear growth fits int64).
fib(1000) now produces the correct 209-digit number. fib(100000) matches Ruby output (20899 digits).
Performance (fib(100000)): Spinel compute: 0.12s (Ruby: 0.15s — Spinel wins) Spinel to_s: 0.44s (Ruby: 0.15s — to_s O(n^2) bottleneck)
Binary size with gc-sections: fib + to_s: 18KB (vs 30KB monolithic — 40% smaller) compute only: 9KB (mul cluster not linked)
Add benchmark/bm_bigint_fib.rb. 75/75 tests, bootstrap stable.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 6d3a86bac528
- Parent
- 34e359f0f4b9