Repository navigation
t27b: specs/numeric/gf16.t27 after the type mismatch family -- @bitCast, f32 rounding and libm, std.math, @setEvalBranchQuota #7746
Description
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 inspecs/numeric/gf16.t27, When the compiler implements bit-exact f32 reinterpretation, rounding, remainder, log, and power semantics matching the Zig 0.16 reference, Thent27b test specs/numeric/gf16.t27passes all tests without type-mismatch or unsupported-construct errors. - Given
specs/tri/t27b/libm.t27currently holds only f64logandexp/expf, When f32logf,log2f,log10f, andpowfroutines are added following the libm lanes, Then the gf16 spec's@log,@log2,@log10, and@powon 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,isNegativeInfat 8 call sites. - FR-003: t27b MUST support
@intFromBoolat 3 call sites. - FR-004: t27b MUST implement
@floor,@ceil,@round(half away from zero),@truncon f32 via compiler-rtfloorf/ceilf/roundf/truncfwith bit-exact signed-zero and NaN-bit behavior. - FR-005: t27b MUST implement
@remon f32 via compiler-rtfmodfwith dividend-sign semantics. - FR-006: t27b MUST implement
@log,@log2,@log10on f32 via compiler-rtlogf/log2f/log10f; routines MUST be defined inspecs/tri/t27b/libm.t27and wired throught27c gen-rust. - FR-007: t27b MUST implement
@powon f32 via compiler-rtpowf; routine MUST be defined inspecs/tri/t27b/libm.t27. - FR-008: The SSOT
specs/numeric/gf16.t27MUST NOT be modified to accommodate t27b; t27b changes or refuses by construct name.
Success Criteria
t27b test --blockers specs/numeric/gf16.t27reports zero blockers (exit 0)t27b test specs/numeric/gf16.t27passes all tests (exit 0)scripts/tri_loop/t27b.py test specs/numeric/gf16.t27completes with 0 failures (exit 0)- 22
@bitCastsites, 8std.mathsites, 3@intFromBoolsites, 4 rounding builtins, 1@rem, 3 log-family, 1@powall evaluate to bit-exact match against Zig 0.16 reference (verified on t27c lab) specs/tri/t27b/libm.t27contains f32logf,log2f,log10f,powfroutines (4 new routines)
Boundary
- scripts/tri_loop/t27b.py
- specs/tri/t27b/libm.t27
- specs/tri/math/math.t27
Activity
gHashTag commentedon Oct 8, 2026
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.
gf16_encode_f32,gf16_decode_to_f32andgf16_round_phihold the fn-level@bitCastsites andstd.math.nan. They are reached by most tests.@bitCastsites, thestd.mathpredicates and the 3@intFromBoolsit in test bodies.gf16_floor,gf16_ceil,gf16_round,gf16_trunc,gf16_fmod,gf16_log,gf16_log2,gf16_log10andgf16_poweach have 1 to 5 direct tests:gf16_log2_eight,gf16_log10_ten,gf16_pow_two_cubedand others.So gf16 needs real, bit-exact
floorf,ceilf,roundf,truncf,fmodf,logf,log2f,log10fandpowf.A note for the first PR.
@bitCastbetween 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 inlibm.t27, asexpandlogare, operating on those bits.t27b: @bitcast between an integer and a float of one size, @intFromBo…
t27b: @floor, @ceil, @round, @trunc and @Rem of an f32 call t27 ports…
t27b: @log, @log2 and @log10 of an f32 call t27 ports of compiler_rt (C…
t27b: std.math.pow of an f32 calls a t27 port of Zig's pow.zig, and g…
gHashTag commentedon Oct 9, 2026
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.