mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-24 06:14:01 +08:00
A module-level number that only its file's top-level code reads and writes (an initializer binding) was already analyzed like a local, so its loop arithmetic was proven int32, but it kept its double global. A loop-carried `v = step(v, n)` at top level therefore converted v to a double and back on every iteration: LLVM promotes the global to a register, but cannot fold fptosi(sitofp) through the double phi. When every write is a proven int32 (or uint32), the initializer now keeps the binding in an i32 local that starts at the global's zero value. Nothing else can observe the global: no other function reads or writes it, the guard runs the body at most once, library builds have no initializer bindings, and import-cycle bindings (checked through their initialization flag elsewhere) keep their global. Debug builds keep the global for the variable view. The top-level closure kernel's v becomes an i32 local. Corpus 5324 pins localized call results, inline remainders, uint32 hashes, labeled exits and ++/--, and the bindings that must stay doubles or globals (growth past int32 and 2^53, -0, fractions, NaN, reads by other functions and closures) against Node.