Skip to content

Run counted loops from an unproven start as integer loops - #845

Merged
ctate merged 1 commit into
perf/fold-constant-globalsfrom
perf/parser-hot-paths
Oct 11, 2026
Merged

ctate merged 1 commit into
perf/fold-constant-globalsfrom
perf/parser-hot-paths

Conversation

@cramforce

Copy link
Copy Markdown
Contributor

for (let i = start; i < end; i++) kept a double counter when the start had no proven integer range, as in a hash over [start, end) whose bounds come from fields. Such a loop is now versioned like one with an unproven limit. When the start is an exact integer of at most 2^53 − 1 in magnitude, the integer-counter copy runs. The test compares bit patterns, so −0 takes the original loop. The usual bounds on duplicated bodies apply.

On its own this is within noise on tsc-ts as it stands. It is what lets tsc-ts drop the subarray views in its comment and template scanners (tsc-ts PR below), which gives tRPC −2.5 points and Excalidraw −1.6 points. Corpus additions in exact-index-round-trip.ts observe the counter itself (−0, fractions, NaN, ±2^53, 1e300, −Infinity starts). Unit test in integer-loops.test.ts.

Fourth of four. Whole-stack effect on tsc-ts (with two small tsc-ts scanner commits): parse −9 to −11%, single-threaded total −2.5 to −5.7%, --checkers 8 wall −1.9 to −10.1%, diagnostics identical.

`for (let i = start; i < end; i++)` kept a double counter when the start had
no proven integer range, as in a hash over `[start, end)` whose bounds come
from fields. Such a loop is now versioned like one with an unproven limit:
when the start is an exact integer of at most 2^53 - 1 in magnitude (compared
bit for bit, so -0 takes the original loop), the integer-counter copy runs.
The usual bounds on duplicated bodies apply.
@vercel

vercel Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptc Ready Ready Preview, v0 Oct 11, 2026 1:23am UTC

@ctate
ctate merged commit 059b021 into perf/fold-constant-globals Oct 11, 2026
74 of 84 checks passed

This branch was successfully deployed

1 active deployment
Preview — 2b056343 Deployed Oct 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants