Skip to content

feat(t27b): compile integer casts natively, checked like @intCast - #6065

Merged
gHashTag merged 4 commits into
masterfrom
claude/t27b-cast
Oct 4, 2026
Merged

gHashTag merged 4 commits into
masterfrom
claude/t27b-cast

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Stacked on #6064. This branch contains #6064's commit. Once #6064 merges, the diff is only the cast commit.

What

x as T between integer types, and from bool, now lowers to native AArch64. This was step 1 of the --blockers greedy order: 18 files needed nothing else.

  • Lossless casts widen, and bool becomes 0 or 1.
  • Unsigned to narrower unsigned truncates, like Zig's @truncate.
  • Every other narrowing is checked, like @intCast. A value outside the target type traps at a new site kind, TrapKind::Cast (brk #7 in an object file). The check is an extend-compare (cmp w, w, sxtb etc.), plus a sign test when an unsigned 32- or 64-bit source goes to a signed type.
  • Wrap mode truncates every narrowing.
  • A constant operand is folded, and a literal that does not fit is rejected.
  • Casts to or from a float, and casts to bool, stay rejected.

t27b chooses the semantics by type. The Zig backend chooses @truncate vs @intCast from the expression's shape. The README describes the difference.

Corpus numbers (t27b corpus specs)

before (#6064) after
pass (all tests) 36 (36 tests) 54 (109 tests)
test fails 0 0
rejected 1129 1111
front-end error 20 20
JIT/interpreter mismatch 0 0

Newly passing:

  • gft_signed_dot4_jtag
  • port/tools/ternary_model
  • ternary: bitnet_majority, comb_bitnet_layer, comb_bitnet_neuron, comb_ternary_dot, gft_dot2, gft_dot4, gft_exp2, gft_layer2, gft_log2, gft_mul_rne, gft_nll, gft_recip, ternary_full_adder, ternary_mac, ternary_ripple_adder, ternary_xor

Differential

  • The random generator now emits casts (checked and truncating) and bool widening.
  • A new test, casts_at_edge_values, runs every source type against every integer target. Each pair is checked in its truncating and checked forms, with constant operands, at every edge value, and the test asserts that cast traps actually fire.
  • Result: 0 mismatches. That run was on this commit's previous base (57c2cfa). The rebase onto master 2ef1ce9 applied cleanly, and the only upstream change was to t27c's compiler.rs. feat(t27b): corpus --blockers lists every construct and the greedy unlock order #6064's tree was rebuilt and passes on the new base.

Refs #5977
Refs #6063

🤖 Generated with Claude Code

`x as T` between integer types, and from bool, lowers to native AArch64.
A lossless cast widens; bool becomes 0 or 1; an unsigned narrowing
truncates like @truncate; every other narrowing is checked and traps at a
new site kind (brk #7). Wrap mode truncates every narrowing. Casts to or
from a float and casts to bool stay rejected.

Corpus: 36 -> 54 passing files (109 tests), 0 failing, 0 JIT/interpreter
mismatches. The differential generator emits casts and bool widening, and
casts_at_edge_values runs every integer cast at its edge values.

Refs #5977

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag and others added 2 commits October 4, 2026 22:18
The updated blockers branch carries master's memory lane (Slot, Data,
Load, Offset, Bounds, Seq; Val::P / Val::M; Program data, internal_abi,
unchecked). Both sides kept: ExprKind::Cast and TrapKind::Cast = 7 next
to TrapKind::Bounds = 16 and the memory expressions in ir, eval and
codegen; lower's ExprCast arm and cast() next to the struct arms and
unknown_name, with cast() rejecting a pointer or struct operand as
ExprCast. differential: the seq/chain thresholds rebalanced around the
cast lane (seq < 94, chain < 96), traps indexed by TrapKind, the cast
test's Program gets the new fields.

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

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-04 15:31:50 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 42
PRs with All Checks Green 8
READY 6
FAILING 42
PENDING 0
NO CHECKS YET 0

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

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=32e37152eb23 != 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).

Brings the branch up to master a9650c0; no files under cli/t27b change.

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

gHashTag commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

Merged origin/master (a9650c0) into the branch; tip d082cbc (on top of afa41bf). cli/t27b content equals the tree tested below.

  • cargo check -p t27b --tests: ok
  • cargo test -p t27b: all suites pass (differential 4/4, 337 s)
  • check_now_entry_shape.py: OK
  • t27b corpus specs (debug build, --jobs 4): 1193 files; 89 supported and all tests pass (327 tests, 94 invariants); 1 supported with a failing test; 1073 rejected; 20 front-end errors; JIT/interpreter mismatch 0; codegen limit 0; timeout 10; crash 0.

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-04 15:57:04 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 42
PRs with All Checks Green 8
READY 6
FAILING 42
PENDING 0
NO CHECKS YET 0

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

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=32e37152eb23 != 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 merged commit fa3648b into master Oct 4, 2026
24 of 25 checks passed
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.

1 participant