Repository navigation
refactor(comp): a round of simplifications, 65,994 -> 65,940 ttok - #2088
Merged
Merged
Conversation
- f32_text writes the fixed form with %.*f, which rounds where the scientific form does; a whole number pads the digits with zeros (same output on every float32, checked exhaustively) - the runtime's host globals and their device stand-ins (KEEP_WORDS, f32_show, f32_read, corpus_grow) share Globals' one DEVICE split - facts_hot names its forced recursion hot; nat_is_lt needs no $o; ctr_adt and anf use tld_of and ty_all - io_wait's caller already checks waits is non-empty Every emitted program differs from main only by these runtime lines. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- io_wait keeps its fallback for an empty waits list - anf's Lam case calls tele_open, which may give null, and binds the instantiated body once - facts_hot builds hot only in the branch that uses it, and passes it to forEach directly Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A round of simplifications in
bend2/comp.ts: 65,994 → 65,940 ttok (−54; the cap is 66k), in that file only.The file has been through many rounds already; four independent passes (compiler front, compiler back end, C runtime, JS runtime) found little left that simplifies rather than golfs. Everything here keeps the file's style, and no cache is touched.
What changes
C runtime
f32_textwrites the fixed form withsnprintf("%.*f", p - ex), which rounds at the same place, 10^(ex − p), as the scientific form did; a whole number moves the digits over the point and pads with zeros. This replaces copying the digits intod[9]and rebuilding the string place by place.KEEP_WORDS, thef32_show/f32_readstubs,corpus_grow) shareGlobals' one#if !DEVICE … #elsesplit, instead of three separate ones.Compiler
facts_hotnames its forced recursionhot, built only in the branch that uses it, instead of repeatingfacts_hot(def, x, true, local)three times.nat_is_ltneeds no$osubstitution.ctr_adtuses the existingtld_of.anf'sLamcase binds the instantiated bodyall.B(DUMMY)once instead of computing it twice.Verification
bend f -o f.cand-o f.json all 1,935 test, demo and bench programs, againstmain(ca77ef2). Every compile error is identical. Every.jsis identical tomain's, and every.cdiffers from it by the same single diff, which is exactly the C runtime edits above. So no compiler change alters any output.f32_text: compared bit for bit with the old function on every float32 from 0x33000000 to 0x63000000, both signs (about 1.6 billion values, past both cut-offs), every denormal, inf and nan: 0 differences.gates/repo.ts: 56 / 56.gates/test.ts: 1,847 / 1,847. An earlier run on the same commit had 4 misses that didn't repeat.gates/perf.ts: 124 / 124 on a rerun. The first run's one miss, queens PAR-CPU at 1.39x, read 1.02x on the rerun, and also 1.02x onmainrun right after.%fis exact too, so thef32_textargument holds there, but it was run only on macOS.🤖 Generated with Claude Code