Skip to content

feat(t27b): lower type f32 in s registers (Closes #6448) - #6456

Merged
gHashTag merged 2 commits into
masterfrom
t27b-f32-6448
Oct 5, 2026
Merged

gHashTag merged 2 commits into
masterfrom
t27b-f32-6448

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Closes #6448
Refs #6063

What

  • Ty::F32 in the t27b IR, interpreter and AArch64 backend. Values live in s registers, canonical like a u32. The encodings are the double ones with bit 22 clear, plus fmov s/w and fcvt between precisions. It shares the f64 path from feat(t27b): f64 in AArch64 FP registers (Closes #6180) #6286 through fp_in / fp_out / fp_op in codegen.rs.
  • Literals round the way Zig rounds comptime_float -> f32.
    • An inexact literal whose f64 is exactly an f32 rounding boundary is refused. Zig rounds the f128, and the f64 cannot tell the cases apart: 1.0000000596046447753906250001 gives 0x3f800001 in Zig and 1.00000005960464477539062499 gives 0x3f800000, yet both are the same f64.
    • An integer literal must be exactly an f32. 16777217 is a Zig compile error.
  • Conversions:
    • f32 mixed with f64 peers to f64, which is exact.
    • @floatCast with a result type rounds to nearest even and gives inf on overflow, matching Zig's runtime cast.
    • @floatFromInt and an int as f32 round once, straight from the integer.
    • @intFromFloat from an f32 goes through the f64 bounds check.
  • The lowering helpers are in a new child module, cli/t27b/src/lower_float.rs. The hooks in lower.rs are small, to stay clear of the parallel lanes.
  • Still refused: a float-operand as, @floatCast of a literal or with no result type, and x * 2^k on f32 (the t27c shift bug t27c gen: strength_reduce turns f64 x * 2 into x << 1 (does not compile) #6284).

Tests

  • Encoder: 14 single-precision words, checked against clang -arch arm64 + objdump. Disassembler read-back covers the new forms.
  • Differential, interpreter vs JIT, bit for bit over the f32 edge values (signed zeros, infinities, NaN payloads, subnormals, 2^24, the int bounds):
    • + - * /, negation, the six compares as values and as branches, and f64 round-trips.
    • @floatFromInt / @intFromFloat for every int type, including the traps.
    • @floatCast in both directions, including exact f32 midpoints.
    • AAPCS64 calls with s, d and x registers interleaved.
  • A source program whose verdicts equal t27c test-report (Zig 0.16): one pass, and one @intFromFloat trap.
  • cargo test -p t27b: all green.

Corpus (t27b corpus specs --blockers --reference <t27c> --reference-cache, jobs 6, load avg ~200-300)

counted (t27b pass where reference passes) reference pass mismatch fail
before, master f6336ac 379 723 0 8
after, same base 382 (+ d_g22_test passing again after a load timeout = 383) 723 0 8
after, rebased on 11f5e6a 384 (master adds specs/tri/catalog/health.t27) 724 0 8

Newly passing f32 files: specs/benchmarks/bench_nn.t27, specs/brain/unified_state.t27, specs/port/trios/crates/trios-trinity-brain/src/phi.t27.

type f32 is no longer a blocker anywhere; its 1224 occurrences are gone. In the other 4 lab files that started on f32, the next blockers are StmtAssign(undeclared) x2, @exp and @sqrt.

🤖 Generated with Claude Code

Single precision reuses the f64 FP-register path: s registers, fcvt
between precisions, int<->f32 conversions, comparisons, and literals
rounded like Zig's comptime_float -> f32 (inexact literals whose f64 is
an f32 rounding boundary are refused). Corpus with the reference:
counted 379 -> 382 of 723, mismatch 0.

Closes #6448
Refs #6063

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

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-05 15:22:51 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 39
PRs with All Checks Green 11
READY 9
FAILING 39
PENDING 0
NO CHECKS YET 0

These columns do not partition: 9 + 39 + 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)=9f2c8a4829f6 != 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).

…: float, tuple)

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

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-05 15:34:25 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 39
PRs with All Checks Green 11
READY 9
FAILING 39
PENDING 0
NO CHECKS YET 0

These columns do not partition: 9 + 39 + 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)=9f2c8a4829f6 != 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 9041d0d into master Oct 5, 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.

t27b: lower type f32 (single precision in s registers)

1 participant