Skip to content

t27b: a narrow signed @mod widens to the i64 routine -- arena_heap and file_io_contract pass (Closes #10423) - #10431

Merged
gHashTag merged 3 commits into
masterfrom
t27b-mod-widen
Oct 18, 2026
Merged

gHashTag merged 3 commits into
masterfrom
t27b-mod-widen

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

Closes #10423

Follow-up to #10405 / #10410 (t27b coverage epic #6063).

What

Before this PR, a signed @mod lowered only for i64. A narrower signed @mod was refused with ExprCall(@mod) (REFUSE_WIDTH). Now it widens:

  • Both operands are widened to i64. The second operand first takes the first one's type.
  • They go through the existing __t27b_libm_mod.
  • The result is narrowed back with a truncating cast. That loses nothing because 0 <= r < b and b fits the operand type.

Choice, recorded in specs/tri/t27b/libm_plan.t27: widen and narrow, not one mod routine per width. The per-width approach would need a routine for each of i8, i16, i32 and every odd width. Widening needs one routine and one rule (CALL_WIDE, widens()).

A signed @mod wider than i64 (the new kind K_WIDE, e.g. i65, i128) stays refused with REFUSE_WIDTH, since there is no i128 routine. An integer @rem of any width stays t27b's %.

Files

  • specs/tri/t27b/libm_plan.t27: K_WIDE, CALL_WIDE, widens(), and a new test a_narrow_signed_mod_widens_to_the_i64_routine. The kind test now covers i63/i64/i65/i128/u128/f128.
  • gen/rust/tri/t27b/libm_plan.rs: regenerated with t27c gen-rust.
  • cli/t27b/src/lower.rs: the libm_call glue wraps the arguments in Widen and the call in Cast when xp::widens(a). Net change is -1 line (6+/7-).
  • specs/tri/t27b/conformance/rem_int.t27: adds i32/i16/i8/i7 @mod extremes and a sweep against the i64 one. It also adds the corpus's own i32 mods as written: millis from reel_particles_mux and is_pow2 from arena_heap. No new file.
  • Seals re-saved for libm_plan and conformance/rem_int.
  • docs/reports/t27b_expectations.json: specs/ml/arena_heap.t27 and specs/ml/file_io_contract.t27 move to pass, and max_not_pass goes from 77 to 75.

Evidence (Railway lab, t27b aarch64 under qemu, t27c release)

spec t27b test --check t27c test-report
conformance/rem_int.t27 8/8 pass, 542 asserts 8 pass, 0 FAIL, 0 vacuous
libm_plan.t27 17/17 pass, 1268 asserts 17 pass, 0 FAIL, 0 vacuous
ml/arena_heap.t27 10/10 pass, invariant held (seal MATCH)
ml/file_io_contract.t27 12/12 pass, invariant held (seal MATCH)

t27b test --blockers no longer lists ExprCall(@mod) for arena_heap, file_io_contract or specs/t27f/reel_particles_mux.t27. reel_particles_mux is still blocked, now only by ExprCall(std.*) (6 std.debug.print sites). That is outside this issue, and the spec has no ledger row.

No timing here is a speed result (qemu).

🤖 Generated with Claude Code

gHashTag and others added 3 commits October 18, 2026 18:26
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t pass (Closes #10423)

gen/rust/tri/t27b/libm_plan.rs regenerated with t27c gen-rust on the
Railway lab. Seals for libm_plan and conformance/rem_int re-saved.
The ledger moves specs/ml/arena_heap.t27 and specs/ml/file_io_contract.t27
to pass, so max_not_pass goes from 77 to 75.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-18 11:47:18 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 49
PRs with All Checks Green 1
READY 0
FAILING 49
PENDING 0
NO CHECKS YET 0

These columns do not partition: 0 + 49 + 0 + 0 = 49, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=fad12492937a != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@gHashTag
gHashTag enabled auto-merge (squash) October 18, 2026 12:04
@gHashTag
gHashTag merged commit cc598ec into master Oct 18, 2026
31 of 40 checks passed
gHashTag added a commit that referenced this pull request Oct 18, 2026
…ng it (Refs #10431) (#10453)

cc598ec (#10431) added `ri_is_pow2` to specs/tri/t27b/conformance/rem_int.t27
as a byte-for-byte copy of specs/ml/arena_heap.t27's `is_pow2`. That is a new
duplicate body no ledger holds, so the Duplicate Body Ratchet has been red on
master since 89254d2.

rem_int now says `use ml::arena_heap;` and asserts on `is_pow2` itself, the way
libm_logf.t27 uses tri::t27b::libm. The 7 asserts are unchanged; the ledger is
not touched (the corpus goes 686 -> 684 bodies, 197 -> 196 groups).

Seal of rem_int re-saved through `t27c seal --save` (its closure now holds
arena_heap). On the Railway lab: dupe_scan ok, `t27c check` ok,
`t27c test-report` 8/8 pass (12 runtime asserts in the corpus test), and
`t27b build --elf` accepts the file.

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

t27b: a signed @mod of any width up to i64 widens to the i64 routine (arena_heap, file_io_contract, reel_particles_mux)

1 participant