Skip to content

t27b: specs/numeric/gf16.t27 after the type mismatch family -- @bitCast, f32 rounding and libm, std.math, @setEvalBranchQuota #7746

Closed
4 of 4 issues completed

Description

@gHashTag

Part of #6063 (t27b coverage), which is item C10 of #6488. Follows #7740.

specs/numeric/gf16.t27 is the numeric single source of truth (law L6, with FORMAT-SPEC-001.json). The reference passes all of its tests. After #7740 t27b has no type mismatch left in it, and its first blocker is ExprCall(@bitCast). Every construct t27b still refuses there (t27b test --blockers, t27c lab, branch of #7740):

construct sites what the reference runs (zig 0.16, no libc)
ExprCall(@setEvalBranchQuota) 47 done by #7459 (a compile-time no-op)
ExprCall(@bitCast) 22 f32 <-> u32 bit reinterpretation
ExprCall(std.*) 8 std.math.nan(f32) (3), isNan (2), isPositiveInf, isNegativeInf, std.math.pow(f32, ..)
ExprCall(@intFromBool) 3 0 or 1
@floor, @ceil, @round, @trunc on f32 1 each compiler_rt floorf / ceilf / roundf / truncf; @round is half away from zero
@rem on f32 1 compiler_rt fmodf; the sign follows the dividend
@log, @log2, @log10 on f32 1 each compiler_rt logf, log2f, log10f (specs/tri/t27b/libm.t27 holds only the f64 log and exp/expf)

Each value must be bit-exact against the reference: signed zero, NaN bits and the rounding of @round are to be measured on the t27c lab, not assumed. The f32 routines follow the libm lanes (#7645, #7648): a t27 routine in libm.t27, a plan through t27c gen-rust, tests held to Zig's own results.

The SSOT itself is not to be changed to make t27b pass: t27b changes, or refuses by name.

A possible split, one PR each: @intFromBool + @bitCast + the std.math predicates and nan; the f32 rounding builtins and @rem; logf, log2f, log10f; powf.

User Scenarios

  • Given the t27b compiler refuses ExprCall(@bitCast) and f32 math builtins in specs/numeric/gf16.t27, When the compiler implements bit-exact f32 reinterpretation, rounding, remainder, log, and power semantics matching the Zig 0.16 reference, Then t27b test specs/numeric/gf16.t27 passes all tests without type-mismatch or unsupported-construct errors.
  • Given specs/tri/t27b/libm.t27 currently holds only f64 log and exp/expf, When f32 logf, log2f, log10f, and powf routines are added following the libm lanes, Then the gf16 spec's @log, @log2, @log10, and @pow on f32 evaluate to bit-exact results against the reference.

Requirements

  • FR-001: t27b MUST support ExprCall(@bitCast) for f32 <-> u32 bit reinterpretation at 22 call sites in gf16.t27.
  • FR-002: t27b MUST support ExprCall(std.math.nan(f32)), isNan, isPositiveInf, isNegativeInf at 8 call sites.
  • FR-003: t27b MUST support @intFromBool at 3 call sites.
  • FR-004: t27b MUST implement @floor, @ceil, @round (half away from zero), @trunc on f32 via compiler-rt floorf/ceilf/roundf/truncf with bit-exact signed-zero and NaN-bit behavior.
  • FR-005: t27b MUST implement @rem on f32 via compiler-rt fmodf with dividend-sign semantics.
  • FR-006: t27b MUST implement @log, @log2, @log10 on f32 via compiler-rt logf/log2f/log10f; routines MUST be defined in specs/tri/t27b/libm.t27 and wired through t27c gen-rust.
  • FR-007: t27b MUST implement @pow on f32 via compiler-rt powf; routine MUST be defined in specs/tri/t27b/libm.t27.
  • FR-008: The SSOT specs/numeric/gf16.t27 MUST NOT be modified to accommodate t27b; t27b changes or refuses by construct name.

Success Criteria

  • t27b test --blockers specs/numeric/gf16.t27 reports zero blockers (exit 0)
  • t27b test specs/numeric/gf16.t27 passes all tests (exit 0)
  • scripts/tri_loop/t27b.py test specs/numeric/gf16.t27 completes with 0 failures (exit 0)
  • 22 @bitCast sites, 8 std.math sites, 3 @intFromBool sites, 4 rounding builtins, 1 @rem, 3 log-family, 1 @pow all evaluate to bit-exact match against Zig 0.16 reference (verified on t27c lab)
  • specs/tri/t27b/libm.t27 contains f32 logf, log2f, log10f, powf routines (4 new routines)

Boundary

  • scripts/tri_loop/t27b.py
  • specs/tri/t27b/libm.t27
  • specs/tri/math/math.t27

Activity

  1. gHashTag commented on Oct 8, 2026

    @gHashTag
    OwnerAuthor

    Every remaining construct is reached by a test. This was measured after #7747 and #7749, with t27b on 1d9c596. I mapped each blocker line to its enclosing fn, and walked the calls from the 201 tests with comments stripped.

    • None of these fns is unanalyzed, so treating a body Zig never analyzes as a stub would clear nothing.
    • gf16_encode_f32, gf16_decode_to_f32 and gf16_round_phi hold the fn-level @bitCast sites and std.math.nan. They are reached by most tests.
    • 17 more @bitCast sites, the std.math predicates and the 3 @intFromBool sit in test bodies.
    • gf16_floor, gf16_ceil, gf16_round, gf16_trunc, gf16_fmod, gf16_log, gf16_log2, gf16_log10 and gf16_pow each have 1 to 5 direct tests: gf16_log2_eight, gf16_log10_ten, gf16_pow_two_cubed and others.

    So gf16 needs real, bit-exact floorf, ceilf, roundf, truncf, fmodf, logf, log2f, log10f and powf.

    A note for the first PR. @bitCast between f32 and u32 may not need a new IR node. t27b holds an f32 as its 32-bit pattern, so a store of the f32 to a frame slot, then a u32 load of that slot, reinterprets it with the IR that exists. The f32 routines can then be t27 in libm.t27, as exp and log are, operating on those bits.

  2. added 4 commits that reference this issue on Oct 8, 2026
  3. gHashTag commented on Oct 9, 2026

    @gHashTag
    OwnerAuthor

    Done: specs/numeric/gf16.t27 passes under t27b on master, 201/201 tests, 465 runtime asserts, the same verdicts as t27c test-report. The series is #7818, #7863, #7918, #7925 and #8167; the last one turned gf16 from blocked to pass, with an IMPROVED_ONLY receipt.

    Debt: the series added +111 hand-written lines under cli/t27b/, before the 2026-10-09 rule that t27b is generated entirely from .t27. A port of lower_float.rs, to offset them, follows as its own PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions