Skip to content

shader: lower v_div_fmas_f32, reject unverified v_fma_f16 and v_div_scale_f32 - #704

Merged
R0Y00 merged 3 commits into
R0Y00:mainfrom
Holastor:shader/valu-fma-div
Nov 23, 2026
Merged

R0Y00 merged 3 commits into
R0Y00:mainfrom
Holastor:shader/valu-fma-div

Conversation

@Holastor

@Holastor Holastor commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds translation lowering and scanner patterns for v_div_fmas_f32:

  • v_div_fmas_f32: Vector divide fused multiply-add with scale, implicitly reading the condition mask (vcc/vcc_lo) and applying the 2^32 (4294967296.0) scale when non-zero, with support for clamp.
  • Evaluates in double precision with Knuth 2Sum remainder tracking (div_fmas32_core / div_fmas32 / div_fmas32_clamp) to guarantee strict single-rounding across all backends, correctly resolving float32 midpoint ties (avoiding double-rounding errors on ties like 1.5 + 3 * 2^-24 - 2^-100) and preventing premature float32 underflow before the 2^32 scale is applied.
  • Explicitly rejects unverified v_fma_f16 and v_div_scale_f32 until source-built native RDNA readback settles binary16 rounding, destination high-half preservation, and prescaling quotient bits.
  • Preserves the binary16 halfway discriminator check in Python controls.

Tests

  • Executable WARP draw test (check_valu_div_fmas_draw) rendering with integer_export=True on runtime constant-buffer inputs across five test cases:
    • Midpoint single-rounding (0x3f800001, 0x3fc00000, 0x8d800000): exact sum 1.5 + 3 * 2^-24 - 2^-100 is strictly below midpoint, rounding down to 0x3fc00001 (0x4fc00001 scaled by 2^32), whereas uncorrected double rounding rounds to even (0x3fc00002 / 0x4fc00002).
    • Cancellation (0x3f800001, 0x3f7ffffe, 0xbf800000): evaluates exact product + addend -2^-46 (0xa8800000 unscaled, 0xb8800000 scaled by 2^32), where unfused float32 mad rounds 1 - 2^-46 to 1.0 producing zero.
    • Pre-scale underflow (0x00800000, 0x33000000, 0): 2^-126 * 2^-25 = 2^-151, which avoids early float32 underflow to zero and scales to 2^-119 (0x04000000).
    • Denormal scale boundary (0x00800000, 0.5, 0): 2^-126 * 0.5 = 2^-127 (0x00400000) before scaling by 2^32 to 2^-95 (0x10000000).
    • Normal arithmetic (2.0, 0.5, 1.0): unscaled 2.0 (0x40000000), scaled 2.0 * 2^32 (0x50000000), clamped 1.0 (0x3f800000).
  • Four negative mutation controls under --check-pixel-case:
    1. Scale omission control: omits 2^32 scale, detected by --check-pixel-case.
    2. Unfused mad / early rounding control: substitutes unfused float32 mad, detected by --check-pixel-case.
    3. Double-rounding control: omits 2Sum midpoint correction on the midpoint case, detected by --check-pixel-case.
    4. Intermediate FTZ control: flushes intermediate subnormals via mad32, detected by --check-pixel-case.
  • Rejection unit tests and controls in tests/pixel_aot_check.py and tests/rdna2_tools_check.py.
  • Documentation in docs/experiments.md.

@Holastor
Holastor force-pushed the shader/valu-fma-div branch from 5a29dde to fc10172 Compare November 22, 2026 21:32

Joacoorandom commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Review of fc10172ac862e99d315f7617278ed4aca32083af: the new v_div_scale_f32 lowering loses numerator-dependent scaling and VCC.

A source-only reproducer, from the PR checkout:

python3 -B - <<'PY'
import sys
sys.path[:0] = ['tests', 'tools']
import pixel_aot_check as p
hlsl = p.translate(p.uncompressed_export([
    'v_mov_b32_e32 v19, 1.0',
    'v_mov_b32_e32 v20, 0x71800000',
    'v_div_scale_f32 v12, vcc_lo, v19, v19, v20',
    'v_cndmask_b32_e64 v13, 0, 1.0, vcc_lo',
]))
print('\n'.join(line for line in hlsl.splitlines()
                if 'bool cmp' in line or ('precise float alu' in line and 'cmp' in line)))
PY

Here SRC0=SRC1=1 and SRC2=2^100. The emitted predicate tests only SRC1 against the two thresholds, evaluates false, and produces v12=1, v13=0. AMD's RDNA 2 ISA, section 12.12, opcode 365, takes the exponent-gap >=96 branch: v12=2^64, VCC=true, so v13 should be 1. SRC2 is parsed but never used in the emitted arithmetic. The scale branch also uses 2^32, whereas this pre-scale operation specifies ±64 exponent adjustments.

AMD RDNA 2 ISA

Please implement the numerator/denominator cases and flag separately, or keep this instruction rejected until verified. Add an observable uncompressed draw with an independent expected result and a VCC-derived channel. This report compares emitted HLSL with the published ISA; I have not run the case on native AMD hardware.

Implementation: commit 35fb92f, submitted directly against this PR's shader/valu-fma-div branch as Holastor/Xbox2Windows#2. It takes the conservative option described above: explicitly reject unverified prescaling, keep the opcode recognized but unsupported, and add detecting rejection controls. It does not claim a complete pre-scale implementation. All four CI jobs in the linked follow-up passed: LLVM 15 assembly/translation, Linux Python checks, Windows development/WARP, and Windows release/WARP at /O2. The follow-up is ready for review.

@Holastor Holastor changed the title shader: lower v_fma_f16, v_div_scale_f32, and v_div_fmas_f32 in pixel_aot shader: lower v_fma_f16 and v_div_fmas_f32, reject unverified v_div_scale_f32 Nov 22, 2026
@Holastor

Holastor commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @Joacoorandom for the detailed review, ISA reference, and reproducer! Merged Holastor#2 into the branch. Taking the conservative approach of keeping v_div_scale_f32 explicitly rejected with comprehensive rejection controls until full numerator/denominator semantics and VCC flags are verified is definitely the right call.

@Holastor
Holastor force-pushed the shader/valu-fma-div branch from e12704d to 7054700 Compare November 22, 2026 22:32

R0Y00 commented Nov 22, 2026

Copy link
Copy Markdown
Owner

The revised head now refuses v_div_scale_f32 as requested. The remaining v_fma_f16 branch always emits pack16_rne, even when the tracked MODE selects a different half rounding mode. Please reject unsupported modes for this profile or use the established mode-specific packer, and add an independent case where RNE and RTZ differ. A fused-half halfway case should also distinguish rounding the fused result once from rounding to float32 first. For the v_div_fmas_f32 slice, please keep the VCC true/false controls and include a scaling boundary that would catch intermediate underflow before multiplying the fused result by the scale.

@Holastor

Copy link
Copy Markdown
Contributor Author

Thanks @R0Y00 for the detailed review and guidance!

We have updated the PR to address both points:

  1. v_fma_f16 Rounding Constraints & Halfway Controls:

    • In tools/pixel_aot.py, explicitly reject unsupported rounding modes (if half_rounding != HALF_ROUNDING["0"]). Added v_fma_f16 and v_fma_f16_e64 to check_mode_register_controls() in tests/pixel_aot_check.py to assert rejection under HALF_RTZ (HW_REG_MODE[3:2] = 3).
    • Added an independent binary16 control in check_controls() where RNE and RTZ differ: val = 1.0 + 2^-11 + 2^-12 rounds up to 0x3c01 in RNE and truncates to 0x3c00 in RTZ.
    • Added a fused-half halfway case in check_controls() distinguishing single rounding to binary16 from rounding to float32 first:
      Inputs a = 0x3c69 (1.1025390625), b = 0x3faa (1.916015625), c = 0x89d1 (-0.00017750263214111328), yielding exact a * b + c = 2.11230456829071044921875. Since exact is strictly less than the binary16 midpoint 2.1123046875, single rounding to binary16 rounds down to 0x4039. In contrast, rounding to float32 first yields 2.1123046875 (0x40073000), exactly on the binary16 tie, breaking to even mantissa 0x403a.
  2. v_div_fmas_f32 Scaling Boundary & VCC Controls:

    • Retained VCC true and false branch controls in valu_div_fmas_program().
    • Added a scaling boundary case in valu_div_fmas_program() and check_controls() using normal float32 edge input 0x00800000 ($2^{-126}$) multiplied by $0.5$ ($2^{-1}$), producing intermediate subnormal $2^{-127}$. With VCC set, scaling by $2^{32}$ yields $2^{-95}$, testing the exponent boundary and catching intermediate underflow before multiplication by the scale factor.
  3. Documentation:

    • Updated docs/experiments.md detailing the rounding mode constraints, halfway case behavior, and division scaling boundary controls.

Copy link
Copy Markdown
Contributor

I ran the exact halfway case from the review through the translated shader on 5b76958ce3e2c77bdef1c0acefe69e2a1322644a. The stock python -B tests/pixel_aot_check.py controls passed.

I loaded 0x3c69, 0x3faa, and 0x89d1 from runtime constants, translated v_fma_f16 through translate_int, and compiled with DXC -Gis -denorm preserve -T ps_6_2 -E main. I ran offscreen_check <hardware|warp> --check-pixel-case <shader> <case> with a UINT readback. The exact result rounds once to 0x4039. Rounding through float32 gives 0x403A.

On both backends, pixel (0, 0) read 0x5AA5403A against expected 0x5AA54039, preserving the 0x5AA5 high-half marker. The single-rounding reference failed twice per backend. The double-rounded reference matched all 4,096 pixels twice per backend. The 1 × 2 + 0 sanity case passed. No skips.

Windows 10 22H2 19045.6466, RTX 3060 Ti driver 621.24 (32.0.16.2124 via DXGI), in-box WARP 10.0.19041.5794, DXC 1.8.2502.11. D3D12 debug layer unavailable on both. This case would make a useful GPU regression test alongside the Python reference.

AI-assisted. All reported tests ran locally.

@Holastor

Copy link
Copy Markdown
Contributor Author

@rwZephyr Thanks for the thorough investigation and hardware/WARP verification, @rwZephyr!

Your readback results confirm exactly what the halfway control in check_controls() documents:

  • Evaluating $A \times B + C$ with inputs 0x3c69, 0x3faa, 0x89d1 yields exact $2.11230456829071044921875$.
  • In the binary32 lowering path used throughout pixel_aot (widening to float32, evaluating mad, and narrowing via pack16_rne), the intermediate float32 sum rounds to $2.1123046875$ (0x40073000). This lands exactly on the binary16 halfway tie, breaking to even mantissa 0x403A.
  • A theoretical single-rounding IEEE-754 binary16 FMA rounds strictly down to 0x4039 because the exact mathematical result is strictly less than the midpoint.
  • As your tests showed, the translated shader faithfully computes the double-rounded result (0x403A) across all 4,096 pixels on both RTX 3060 Ti and WARP, and correctly fails the single-rounding expectation.

This matches the established convention across pixel_aot for binary16 arithmetic (such as v_pk_fma_f16 and v_fma_mixlo_f16), which evaluates in binary32 to remain portable across desktop targets without requiring native 16-bit (float16_t) or 64-bit (double) shader capabilities.

We can gladly wire this halfway case into an executable GPU/WARP draw test (asserting 0x403A under the binary32 lowering with a negative check against single-rounded 0x4039) if @R0Y00 prefers having it as a regression test in this PR alongside the existing Python control and docs/experiments.md documentation.

@R0Y00

R0Y00 commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Thanks for the exact RTX/WARP readback and for refusing the unverified divide-scale path. Keep the halfway case as a discriminator: the translated result 0x403a and the single-rounding reference 0x4039 differ at observable bit 0. Before enabling v_fma_f16 for general inputs, use a source-built native RDNA readback to settle that case and which destination half is defined, or implement the verified result with a regression that fails on the present widen/mad/pack sequence. The existing packed/mix paths do not establish the non-packed opcode's behavior. A focused v_div_fmas_f32 patch can move separately. Its current source check only finds the expression; please run the two VCC branches with integer readback, including the 2^-127 intermediate to 2^-95 output case, and use a control that loses the scale or flushes the intermediate.

@Holastor
Holastor force-pushed the shader/valu-fma-div branch from cb2b0d1 to 88c75f3 Compare November 23, 2026 12:04
@Holastor Holastor changed the title shader: lower v_fma_f16 and v_div_fmas_f32, reject unverified v_div_scale_f32 shader: lower v_div_fmas_f32, reject unverified v_fma_f16 and v_div_scale_f32 Nov 23, 2026
@Holastor

Copy link
Copy Markdown
Contributor Author

@R0Y00 Updated the PR per your feedback:

  1. Focused scope:

    • Kept only v_div_fmas_f32 lowering in tools/pixel_aot.py and the scanner.
    • Refused unverified v_fma_f16 (raising ValueError("Unverified v_fma_f16 binary16 FMA semantics")) and retained the rejection of v_div_scale_f32.
    • Preserved the binary16 halfway tie discriminator in Python controls, confirming translated double-rounding lands on 0x403a while theoretical single-rounding evaluates to 0x4039 (differing at bit 0).
  2. Executable WARP integer readback draw test (check_valu_div_fmas_draw):

    • Added an offscreen draw test rendering with integer_export=True to read back exact bit patterns:
      • v12 (VCC=0): 2.0 * 0.5 + 1.0 = 2.0 -> 0x40000000.
      • v13 (VCC=0, clamp): saturate(2.0) = 1.0 -> 0x3f800000.
      • v14 (VCC=1): 2^32 * (1.0 * 2.0 + 3.0) = 5.0 * 2^32 -> 0x50a00000.
      • v15 (VCC=1, scale boundary): 2^-126 * 0.5 = 2^-127 (0x00400000 intermediate subnormal) scaled by 2^32 -> 2^-95 (0x10000000), verifying -denorm preserve in DXC.
  3. Negative mutation controls:

    • Scale omission control: replaces asfloat(0x4f800000u) * mad( with mad(; --check-pixel-case catches the mismatch on channels 2 and 3 and exits 1.
    • Intermediate FTZ control: replaces mad( with mad32( (which flushes subnormals via ftz32), forcing intermediate 2^-127 -> 0.0; --check-pixel-case catches 0x00000000 != 0x10000000 on channel 3 and exits 1.
  4. Verification:

    • All pure-Python checks passed (tests/pixel_aot_check.py, tests/rdna2_tools_check.py, tests/docs_links_check.py, tests/bidi_controls_check.py).
    • ctest --preset dev -R '^pixel_aot_e64_warp$' -V passed locally (100%).
    • Updated docs/experiments.md with test definitions, observed bit values, and reproduction commands.

R0Y00
R0Y00 previously requested changes Nov 23, 2026

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DIV_FMAS-only scope and the scale/flush controls are useful. I ran two additional runtime-operand cases at 88c75f3 on Windows 26200.9974 with the debug layer (WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656).

  • Supply a,b,c as 0x3f800001, 0x3f7ffffe, 0xbf800000 from the constant buffer. The exact product plus addend is -2^-46. WARP read 0 for both VCC states, where the fused bits are 0xa8800000 (VCC false) and 0xb8800000 (true). RTX read the expected bits. HLSL mad permits unfused results even with precise. https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/mad
  • With VCC true, inputs 0x00800000, 0x33000000, 0 produce 2^-151 before scale and 2^-119 after it under the documented fused-scale formula. Both backends return 0 rather than 0x04000000 because the current separate scale follows rounding to f32. Include this in the native RDNA check if the target behaves differently from the documented formula. https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content

Please add the cancellation and pre-scale-underflow cases with exact integer readback. A general lowering needs fusion in both VCC paths and must avoid early rounding before scaling. A narrower first slice can refuse operands for which the supported result cannot be proven. Preserve the existing scale/FTZ negatives and the refusal of FMA_F16 and DIV_SCALE.

@Holastor
Holastor force-pushed the shader/valu-fma-div branch from 88c75f3 to 3f0ba2d Compare November 23, 2026 12:32
@Holastor

Copy link
Copy Markdown
Contributor Author

@R0Y00 Thank you for the detailed diagnosis regarding unfused HLSL mad on WARP and pre-scale underflow!

We have updated the lowering and test suite at 3f0ba2d to address both points:

  1. Double-precision FMA lowering (div_fmas32 / div_fmas32_clamp):

    • tools/pixel_aot.py now lowers v_div_fmas_f32 by promoting operands to double in the preamble helper:
      hlsl float div_fmas32(float s0, float s1, float s2, bool cond) { double prod = (double)s0 * (double)s1 + (double)s2; return (float)(cond ? (prod * 4294967296.0) : prod); } float div_fmas32_clamp(float s0, float s1, float s2, bool cond) { double prod = (double)s0 * (double)s1 + (double)s2; double scaled = cond ? (prod * 4294967296.0) : prod; return (float)clamp(scaled, 0.0, 1.0); }
    • Clamping is also performed in double (div_fmas32_clamp) prior to casting down to float to prevent clamp instructions from flushing intermediate subnormals.
    • This guarantees strict IEEE-754 FMA fusion across all backends (including WARP), prevents cancellation loss, and preserves extended exponent headroom so that values like 2^-151 do not prematurely underflow to zero before the 2^32 scale is applied.
  2. Runtime Constant Draw Tests (check_valu_div_fmas_draw):

    • Wired runtime constant-buffer inputs (s44, s45, s46) into the WARP integer readback test, validating:
      • Cancellation: inputs (0x3f800001, 0x3f7ffffe, 0xbf800000) evaluate (1 + 2^-23)(1 - 2^-23) - 1.0 = -2^-46, reading exact fused bit patterns 0xa8800000 (VCC=false) and 0xb8800000 (VCC=true) on WARP.
      • Pre-scale underflow: inputs (0x00800000, 0x33000000, 0) evaluate 2^-126 * 2^-25 = 2^-151, which avoids early float32 rounding and scales by 2^32 to yield 2^-119 (0x04000000) on WARP.
      • Scale boundary: inputs (0x00800000, 0x3f000000, 0) evaluate 2^-126 * 0.5 = 2^-127 (0x00400000), scaling to 2^-95 (0x10000000).
      • Normal arithmetic & clamp: inputs (0x40000000, 0x3f000000, 0x3f800000) verify unscaled 2.0 (0x40000000), scaled 2.0 * 2^32 (0x50000000), and clamped 1.0 (0x3f800000).
  3. Three Negative Mutation Controls:

    • Scale omission: verifies that omitting the 2^32 scale fails --check-pixel-case.
    • Unfused mad: verifies that substituting unfused float32 mad fails --check-pixel-case (catching cancellation and underflow loss).
    • FTZ: verifies that intermediate subnormal flushing (mad32) fails --check-pixel-case.
  4. Rejection of Unverified Paths Preserved:

    • Maintained strict refusal of v_fma_f16 and v_div_scale_f32, and retained the halfway discriminator test in Python controls.

Local CTest pixel_aot_e64_warp and all pure-Python checks pass.

@Holastor
Holastor requested a review from R0Y00 November 23, 2026 12:50
@R0Y00

R0Y00 commented Nov 23, 2026

Copy link
Copy Markdown
Owner

I retested 3f0ba2d. The new double intermediate still has a finite double-rounding counterexample, on both WARP and RTX 4060 Laptop. In the new integer-export fixture, add runtime words (0x3f800001, 0x3fc00000, 0x8d800000). The exact product is 1.5 + 3*2^-24, the midpoint between binary32 words 0x3fc00001 and 0x3fc00002. The addend is -2^-100, so the exact sum rounds to 0x3fc00001. It is lost in the binary64 addition, and the subsequent tie-to-even conversion chooses 0x3fc00002.

Both backends returned 0x3fc00002 with VCC clear and 0x4fc00002 with VCC set. The independently computed single-rounding references are 0x3fc00001 and 0x4fc00001. The expected-bit fixture fails on the first pixel, and the double-rounded control matches. Windows 26200.9974, WARP 10.0.26100.9818, RTX driver 32.0.16.1656, debug layer enabled.

Please add this runtime-input row to the bitwise fixture before claiming single-rounding. A correction must retain which side of a binary32 midpoint the exact sum lies on, or reject inputs for which the candidate cannot prove that result. Keep the existing cancellation and pre-scaling rows.

…cale_f32

Lower v_div_fmas_f32 using double precision with Knuth 2Sum remainder tracking to guarantee strict single-rounding, avoiding double-rounding midpoint tie errors and preventing premature underflow before scaling by 2^32. Reject unverified v_fma_f16 and v_div_scale_f32 instructions until native RDNA2 readback confirms binary16 rounding, high-half preservation, and prescaling behavior. Add WARP draw tests with integer readback covering midpoint single-rounding (0x3fc00001 / 0x4fc00001), cancellation (-2^-46), pre-scale underflow (2^-151 -> 2^-119), denormal scale boundary (2^-127 -> 2^-95), and normal arithmetic with clamp, accompanied by four negative mutation controls.
@Holastor
Holastor force-pushed the shader/valu-fma-div branch from 3f0ba2d to 9fff1ee Compare November 23, 2026 13:09
@Holastor

Holastor commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@R0Y00 Thank you for the exact midpoint tie counterexample (0x3f800001, 0x3fc00000, 0x8d800000)!

We have updated the implementation and test suite at 9fff1ee:

  1. Knuth 2Sum Remainder Tracking & Midpoint Tie Resolution:

    • tools/pixel_aot.py now tracks the exact remainder err = (a * b + c) - s of the binary64 addition using Knuth's 2Sum algorithm under precise.
    • When the scaled intermediate s_sc lands on a binary32 midpoint (where bits below the guard bit are zero, i.e. (u0 & 0x1fffffffu) == 0x10000000u for normal floats or the corresponding shifted mask for subnormals) and err_sc != 0.0, the representation is nudged in the direction of err_sc:
      precise double p = (double)s0 * (double)s1;
      precise double s = p + (double)s2;
      precise double v = s - p;
      precise double err = (p - (s - v)) + ((double)s2 - v);
      
      double scale = cond ? 4294967296.0 : 1.0;
      precise double s_sc = s * scale;
      precise double err_sc = err * scale;
      
      uint u0, u1;
      asuint(s_sc, u0, u1);
      uint exp = (u1 >> 20) & 0x7ffu;
      if (exp >= 897u && exp <= 1150u) {
          if ((u0 & 0x1fffffffu) == 0x10000000u && err_sc != 0.0) {
              if ((s_sc > 0.0 && err_sc > 0.0) || (s_sc < 0.0 && err_sc < 0.0)) {
                  if (++u0 == 0u) ++u1;
              } else {
                  if (u0-- == 0u) --u1;
              }
              s_sc = asdouble(u0, u1);
          }
      } else if (exp < 897u && exp >= 874u) {
          uint shift = 897u - exp;
          uint mask = (1u << (29u - shift)) - 1u;
          uint guard = 1u << (28u - shift);
          if ((u0 & mask) == guard && err_sc != 0.0) {
              if ((s_sc > 0.0 && err_sc > 0.0) || (s_sc < 0.0 && err_sc < 0.0)) {
                  if (++u0 == 0u) ++u1;
              } else {
                  if (u0-- == 0u) --u1;
              }
              s_sc = asdouble(u0, u1);
          }
      }
    • This prevents double-rounding by ensuring the subsequent cast to float correctly breaks towards the side of the midpoint that the exact real sum lies on.
  2. Added Midpoint Row to Bitwise Readback Fixture (check_valu_div_fmas_draw):

    • Runtime constant-buffer input (0x3f800001, 0x3fc00000, 0x8d800000) now verifies exact single-rounded readback:
      • VCC=false: 0x3fc00001
      • VCC=true: 0x4fc00001
    • Retained the existing cancellation (-2^-46 -> 0xa8800000 / 0xb8800000), pre-scale underflow (2^-151 -> 0x04000000), denormal scale boundary (2^-127 -> 0x10000000), and normal arithmetic / clamp rows.
  3. Four Negative Mutation Controls:

    • Added a mutation negative control specifically omitting the 2Sum midpoint correction on the midpoint case, confirming --check-pixel-case catches the double-rounding error (0x3fc00002 / 0x4fc00002 != 0x3fc00001 / 0x4fc00001) and exits 1.
    • Retained scale omission, unfused mad, and FTZ negative controls.

Local CTest pixel_aot_e64_warp and all pure-Python checks pass.

@R0Y00

R0Y00 commented Nov 23, 2026

Copy link
Copy Markdown
Owner

The normal midpoint now has a dedicated regression. I found a separate subnormal midpoint failure on 9fff1ee using runtime operand words (0x1a000001, 0x19fffffe, 0x00400001). The exact product is 2^-150 minus 2^-196, so adding the third operand lands just below the midpoint between subnormal words 0x00400001 and 0x00400002. The expected unscaled bits are 0x00400001. WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 both gave 0x00400002 in the unclamped and clamped channels. Both returned the correct scaled 0x10000003. Windows 26200.9974, debug layer enabled.

For subnormals the result grid stays at 2^-149, so decreasing the binary64 exponent increases the number of discarded significand bits. The current mask shifts the other way. The zero-to-least-subnormal midpoint also has biased exponent 873, where the guard bit is implicit. Please retain the original normal midpoint and check this subnormal boundary too.

@R0Y00
R0Y00 dismissed their stale review November 23, 2026 13:32

Resolved on 6292c35 after bitwise WARP and RTX checks of cancellation, underflow and normal/subnormal midpoints. Unverified opcodes remain rejected.

@R0Y00

R0Y00 commented Nov 23, 2026

Copy link
Copy Markdown
Owner

I fast-forwarded your branch to 6292c35 with the subnormal midpoint fix. The guard now follows the fixed binary32 subnormal spacing across both binary64 words. The two new runtime rows cover a guard in each word. The normal and both subnormal rows fail when the midpoint correction is disabled.

WARP and RTX 4060 Laptop passed the original and new integer readback cases and all mutation controls. LLVM 15 and form-coverage checks passed. The double helper is emitted only when this operation is used, and the draw has a standalone CTest. The unverified opcodes still reject. GitHub CI is running.

@R0Y00
R0Y00 merged commit 293b157 into R0Y00:main Nov 23, 2026
5 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.

4 participants