Commit f7c5a480
f7c5a48082beMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
Resolve constant types before ivar inference in the fixpoint
A destructured constant (CLK_1,..,CLK_8 = (1..8).map { |i| i * RP2A03_CC })
is transiently typed poly by infer_write_types before the mapped array's
element type settles to int. infer_ivar_types ran next and a monotonic ivar
reading the constant (@clk += CLK_1) locked onto that transient poly, so
the whole CPU clock cluster stayed boxed even though CLK_* and @clk are
ultimately int.
Run infer_global_const_types + infer_multiwrite_const_types before infer_ivar_types so constants carry their settled type when ivar inference reads them. Resolving constants earlier only narrows, so it can't introduce a spurious widening.
optcarrot CPU @clk (and the clock cluster) de-poly: ~445 -> ~488 fps, checksum 59662. make test 845, make bench 57.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- f7c5a48082be
- Parent
- 094eb02112d5
src/analyze.cmodifiedView file
ch |= infer_default_param_types(c); ch |= infer_block_params(c); ch |= infer_for_index(c); /* Resolve constant types before ivar inference: a destructured constant (`CLK_1,.. = (1..8).map{...}`) is transiently poly in infer_write_types before its array element type settles, and a monotonic ivar that reads it (`@clk += CLK_1`) would lock onto that poly. Resolving constants first feeds the settled type into ivar inference. */ ch |= infer_global_const_types(c); ch |= infer_multiwrite_const_types(c); ch |= infer_ivar_types(c); ch |= infer_cvar_types(c); ch |= infer_inherited_ivars(c); ch |= infer_global_const_types(c); ch |= infer_multiwrite_const_types(c); ch |= infer_return_types(c); if (!ch) break; }