115. Extend element narrowing to 2D grids, nested sequences, and all-ranged tuple elements (2026-11-21)
- Decision. Replace
Program::narrow_elems's flatIntWidthwith recursiveNarrowLayout(Int(IntWidth),Tuple(Vec<IntWidth>),Seq(Box<NarrowLayout>)), narrowing multi-dimensional arrays ([R, C]lo..=hi->cpl::Grid<uint32_t|int32_t, 2>), nested arrays/lists ([D][E]lo..=hi,[D]List<lo..=hi>->std::vector<std::vector<uint32_t|int32_t>>), and sequences of all-ranged tuples ([V](r1, r2)->std::vector<std::tuple<uint32_t|int32_t, ...>>). Flow analysis tracks(ElemLoc, depth)and widens the root container conservatively on any mismatch (plain[R, C]Int/[E]Int/[V](Int, Int)params, incompatible assignments/push/extend/for-binding,mutelement escapes, or non-natural sort). LeafIntandTuplereads widen toll/std::tuple<ll, ...>before arithmetic. - Why. Multi-dimensional DP tables, nested adjacency/bucket tables, and ranged pair lists are among the largest memory consumers in contest solutions; generalizing
NarrowLayouthandles all three with one recursive rule instead of separate passes, while preserving 64-bit arithmetic and interpreter/C++ parity. - Reverse. Restrict
RangeInfo::narrow_elem_layoutincrates/cpl-ir/src/lower/range.rsback to 1DTy::Intsequences only.