Repository navigation
Conversation
AArch64 FPCR.FZ flushed denormal operands and results of the core's 64-bit fadd/fsub/fmul/fdiv/sqrt. They now detect a denormal operand or a flushed result and recompute on a cold path with FZ suspended. Zero operands stay on the fast path, and the denormal test uses integer compares because a float compare reads a denormal as zero under FZ. The f32 paths are unchanged. A differential test (1408 mismatches before) covers it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test the native result with one multiply and one compare (its square is zero, denormal or NaN) and recompute exactly on the cold path. A flushed denormal operand moves a sum or difference only when the result is tiny; products, quotients and roots with one give zero or NaN, and a denormal divisor is tested in fdiv. An exact zero result (an operand zero, or x - x) returns inline instead of calling the cold path: it is the common case. Operand bits are read with fmov, and the recomputation fences its arithmetic with black_box: in an optimized build LLVM turned the bit tests into float compares and moved the division before the FPCR write. The differential test gains infinity, NaN and values around the thresholds, and passes optimized as well as unoptimized. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hecked helpers The multiplier SAT and RND rows had the destination and source bits swapped: PGR Table 12-5 has bit 2 = destination is MR and bit 1 = source is MRB, the oracle had the reverse, so 12 opcodes (0x02-05, 0x0a-0d, 0x1a-1d) decoded to the wrong accumulator or destination. Oracle tests now cover all eight forms in every format against values worked out from the manual, and a generated-core test checks R5 = SAT MRB (SI) and MRF = SAT MRF (SF). The FZ check on the shared f64 helpers is removed again: they serve the 32-bit emulation, where no operand or result can reach the double denormal range. The 64-bit ops (_double_binary, double multiply by single) call their own checked dadd, dsub and dmul (rt/fz/double.rs), through the boundary functions floats._d_add, _d_sub and _d_mul. A test pins the range argument: f32-origin operands give the same results with and without FZ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gap on 64-bit floats Finding 188: the 12 wrong multiplier opcodes (PGR Table 12-5), the 64-bit float helpers split from the shared 32-bit ones, the regeneration (recipes, fingerprint) and the paired counter measurement (B/A 0.999, PCM and state equal). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
m-dwyer
force-pushed
the
fix/sharc-fz-double-ops
branch
from
December 6, 2026 10:05
c7b1c9c to
8fae3fc
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two bugs in the generated SHARC core
1. SAT and RND multiplier rows decoded to the wrong accumulator. PGR Table 12-5 has bit 2 = destination is an accumulator and bit 1 = source is MRB;
sharc_core/compute_mult.pyhad them reversed. Twelve opcodes were wrong (0x02-05, 0x0a-0d, 0x1a-1d). No stock code runs them (the DN2 hits are lookup-table data), so stock audio and state do not change. The fast tier lowers onlyRn = SAT MRF (SF), which was right.2. AArch64 FPCR.FZ flushed 64-bit denormals.
fadd,fsubandfmulserve the 32-bit float emulation (hot) and the 64-bit float unit. The first version of this PR put a result check on the shared helpers. Now the 64-bit paths (_double_binary,mult_double_multiply_single) call their own checkeddadd,dsub,dmul(sharc-rt/src/rt/fz/double.rs) through the boundary functionsfloats._d_add,_d_sub,_d_mul; the shared helpers are origin/main's code again. 32-bit operands are zero or at least 2^-126 and every chain is one op deep, so no 32-bit result can reach 2^-1022. Theblack_boxand opaque-bit-read lessons stay in the checked helpers.Regeneration
out/of a lane is a symlink to the main tree's, so the cores were regenerated intodist/regen/of the lane (main tree's gens untouched), CORE_FINGERPRINT3f80d4b0..., from the PROVENANCE.txt recipes: DN2sharc_rsgen dn2-1.11(send-FX coverage, 2789 blocks), DT2dt2-1.16(r4 coverage, 1241 blocks), shared core bysharc_transpile --strict. Blocks identical to the 2026-11-15 gens; onlycore_g.rs,core_i.rs, tables and fingerprint stamps differ. The main tree's gens still need promoting by whoever ownsout/(finding 188).Tests
tests/sharc/semantics/test_sharc_compute_mr_decode.py: all eight SAT/RND forms in every format, in and out of range, positive and negative, against values worked out from the manual; a decoy in the other accumulator; the named destination only. Two existing oracle tests used the wrong bits and are corrected.sat_rows_use_the_named_source_and_destination(sharc-native, generated core):R5 = SAT MRB (SI),MRF = SAT MRF (SF).checked_double_ops_keep_denormals_under_fz(debug and--release) andshared_helpers_on_f32_origin_operands_ignore_fz(pins the range argument).Measurement (
sharc_cells, one host binary, A = main gens, B = regenerated, 20/24 s)trig1-holddt2-sample-trigGate
mise run test:changed: 19 unit and static tasks passed; rig preflight 17 halves, 0 problems.SHARC_GEN_DIR_DN2/_DT2):pnpm nx:pilot run-many -t smoke,pins -p gate-smoke,gate-pins: 13 ok, 0 failed, 800 s.test:allnot run yet; at merge the gate adds the smoke set.Finding:
docs/findings/188-sharc-sat-rnd-decode-and-f64-fz.md[V].🤖 Generated with Claude Code