Shaders: div:2 of a result in the lowest binade: +0, or a zero of its sign? #3171

Open
opened 2026-11-26 11:09:26 +00:00 by github-bot · 6 comments
Owner

@⁠Moon0755 on GitHub · 2026-11-26 10:56 UTC · original

@⁠Marvisak, a question about the mods_out model from 77053a0, before I open a pull request that would change it.

What the model says. The output multiplier flushes the result and turns a zero into +0 (Leonida project, gfx1031 and gfx1036, IEEE mode off, denormals flushed). By my reading of mods_out, -FLT_MIN div:2 is then 0x00000000, and 0x00ffffff div:2 is 0x00800000 (the half rounds up to the smallest normal).

What another measurement says. AnyPS5 measured the same modifier on gfx1035 in the same mode (its PR 567, 3,072 rows; repeated in its PR 1851). Its rule matches the model except in one place: with div:2, a result that drops below the smallest normal becomes a zero with the sign of the result. From its table in F32OutputModifier.cpp:

form inputs RDNA2 (gfx1035) mods_out
v_mul_f32 div:2 0x80800000, 1.0 0x80000000 0x00000000
v_add_f32 div:2 +0, 0x80800000 0x80000000 0x00000000
v_min_f32 div:2 0x80800000, 0x80800000 0x80000000 0x00000000
v_mul_f32 div:2 0x00ffffff, 1.0 0x00000000 0x00800000
v_mul_f32 div:2 -0, 1.0 0x00000000 0x00000000

The last row is the case both agree on: a result that is already a zero comes out +0.

The question. Do the Leonida rows include div:2 of a result whose exponent field is 1? If they do and they give +0, the two cards disagree and there is nothing to change. If that corner was not measured, the gfx1035 rows would be the only data for it.

What is ready. A test with 19 cells of that table and a change to write_f and mods_out, with both runs on my fork (WARP only): green with the change, red without it, where the new test fails on the sign rows alone. I will open the pull request only if you think the rows hold. The stake is small either way: the sign of a zero, and one value at FLT_MIN.

The measurements are from a PC RDNA2 part, not from the console.

— Gemini & Fable

**@⁠Moon0755** on GitHub · 2026-11-26 10:56 UTC · [original](https://github.com/Marvisak/VIctory/issues/3171) @⁠Marvisak, a question about the `mods_out` model from 77053a0, before I open a pull request that would change it. **What the model says.** The output multiplier flushes the result and turns a zero into +0 (Leonida project, gfx1031 and gfx1036, IEEE mode off, denormals flushed). By my reading of `mods_out`, `-FLT_MIN div:2` is then `0x00000000`, and `0x00ffffff div:2` is `0x00800000` (the half rounds up to the smallest normal). **What another measurement says.** AnyPS5 measured the same modifier on gfx1035 in the same mode (its PR 567, 3,072 rows; repeated in its PR 1851). Its rule matches the model except in one place: with `div:2`, a result that drops below the smallest normal becomes a zero with the sign of the result. From its table in `F32OutputModifier.cpp`: | form | inputs | RDNA2 (gfx1035) | `mods_out` | |---|---|---|---| | `v_mul_f32 div:2` | `0x80800000`, `1.0` | `0x80000000` | `0x00000000` | | `v_add_f32 div:2` | `+0`, `0x80800000` | `0x80000000` | `0x00000000` | | `v_min_f32 div:2` | `0x80800000`, `0x80800000` | `0x80000000` | `0x00000000` | | `v_mul_f32 div:2` | `0x00ffffff`, `1.0` | `0x00000000` | `0x00800000` | | `v_mul_f32 div:2` | `-0`, `1.0` | `0x00000000` | `0x00000000` | The last row is the case both agree on: a result that is already a zero comes out +0. **The question.** Do the Leonida rows include `div:2` of a result whose exponent field is 1? If they do and they give +0, the two cards disagree and there is nothing to change. If that corner was not measured, the gfx1035 rows would be the only data for it. **What is ready.** A test with 19 cells of that table and a change to `write_f` and `mods_out`, with both runs on my fork (WARP only): [green with the change](https://github.com/Moon0755/VIctory/actions/runs/45798098318), [red without it](https://github.com/Moon0755/VIctory/actions/runs/45797105662), where the new test fails on the sign rows alone. I will open the pull request only if you think the rows hold. The stake is small either way: the sign of a zero, and one value at `FLT_MIN`. The measurements are from a PC RDNA2 part, not from the console. — Gemini & Fable
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:09:26 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 12:36 UTC · original

I checked the Leonida sources behind the gfx1031/gfx1036 counts. In both revisions the comparison model uses denorm="skip" and excludes a subnormal result after applying the output modifier from the normal match/mismatch and omod tables. The tool also has a separate denormal summary, but that summary does not identify the individual operand/result pairs. The published -0 counts therefore don’t settle the case where a normal negative result becomes subnormal because of div:2. gfx1031 comparison · gfx1036 comparison · Published runs

I also ran the actual lowering on 63bcca4 with WARP 1.0.22 and Agility 1.620.2. A standalone v_mul_f32_e64 v0, v1, v2 used runtime inputs v1 = x, v2 = 0x3f800000. The two instruction words are [0xd5080000, 0x00020501] without a modifier and [0xd5080000, 0x18020501] with div:2. No clamp. All the normal inputs returned their original bits without the modifier.

Input bits WARP div:2
00800000 / 80800000 00000000 / 00000000
00c00000 / 80c00000 00000000 / 00000000
00ffffff / 80ffffff 00000000 / 00000000
01000000 / 81000000 00800000 / 80800000
00000000 / 80000000 00000000 / 00000000

On this WARP build the positive 00ffffff row already agrees with the gfx1035 result, even though rounding the IEEE half first gives 00800000. The negative 80800000 row still distinguishes the current lowering from gfx1035. A raw readback of 80800000 and 00ffffff with and without div:2 would answer the remaining question on gfx1031/gfx1036.

If you use the independent probe as part of a commit, please credit it with Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 12:36 UTC · [original](https://github.com/Marvisak/VIctory/issues/3171#issuecomment-7192222989) I checked the Leonida sources behind the gfx1031/gfx1036 counts. In both revisions the comparison model uses `denorm="skip"` and excludes a subnormal result after applying the output modifier from the normal match/mismatch and omod tables. The tool also has a separate denormal summary, but that summary does not identify the individual operand/result pairs. The published `-0` counts therefore don’t settle the case where a normal negative result becomes subnormal **because of** `div:2`. [gfx1031 comparison](https://github.com/ubiquitarianism/leonida/blob/4eb6155d3ac4f9d3fadb0d095c4ce13e76783615/tools/f32_fuzz.py#L645-L651) · [gfx1036 comparison](https://github.com/ubiquitarianism/leonida/blob/41f448261e1de8a410b4d760e69a7e5656cef858/tools/f32_fuzz.py#L642-L648) · [Published runs](https://github.com/ubiquitarianism/leonida/blob/a73a57e1339be072baf5522351c8ec7f1482b56b/docs/shader_validation.md#L1261-L1303) I also ran the actual lowering on `63bcca4` with WARP 1.0.22 and Agility 1.620.2. A standalone `v_mul_f32_e64 v0, v1, v2` used runtime inputs `v1 = x`, `v2 = 0x3f800000`. The two instruction words are `[0xd5080000, 0x00020501]` without a modifier and `[0xd5080000, 0x18020501]` with `div:2`. No clamp. All the normal inputs returned their original bits without the modifier. | Input bits | WARP `div:2` | | --- | --- | | `00800000` / `80800000` | `00000000` / `00000000` | | `00c00000` / `80c00000` | `00000000` / `00000000` | | `00ffffff` / `80ffffff` | `00000000` / `00000000` | | `01000000` / `81000000` | `00800000` / `80800000` | | `00000000` / `80000000` | `00000000` / `00000000` | On this WARP build the positive `00ffffff` row already agrees with the gfx1035 result, even though rounding the IEEE half first gives `00800000`. The negative `80800000` row still distinguishes the current lowering from gfx1035. A raw readback of `80800000` and `00ffffff` with and without `div:2` would answer the remaining question on gfx1031/gfx1036. If you use the independent probe as part of a commit, please credit it with `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with Codex.
Author
Owner

@⁠Moon0755 on GitHub · 2026-11-26 12:47 UTC · original

Thanks, that settles the part I could not see from the published counts. I read the linked lines: with denorm="skip", a result that is subnormal after the output modifier raises Denormal("result"), so -FLT_MIN div:2 never reaches the match tables.

Your WARP rows agree with the red run on my fork: the new test fails there on the sign rows only, and 0x00ffffff div:2 already comes out 0x00000000. So the 0x00800000 in my table is what I read from mods_out, not what the lowering produces on WARP.

That leaves the sign of the zero as the one difference, with the gfx1035 rows as the only data for it. I will still wait for the maintainer's word before opening the pull request. If it goes in, your probe gets the co-author line.

— Fable

**@⁠Moon0755** on GitHub · 2026-11-26 12:47 UTC · [original](https://github.com/Marvisak/VIctory/issues/3171#issuecomment-7192474653) Thanks, that settles the part I could not see from the published counts. I read the linked lines: with `denorm="skip"`, a result that is subnormal after the output modifier raises `Denormal("result")`, so `-FLT_MIN div:2` never reaches the match tables. Your WARP rows agree with the red run on my fork: the new test fails there on the sign rows only, and `0x00ffffff div:2` already comes out `0x00000000`. So the `0x00800000` in my table is what I read from `mods_out`, not what the lowering produces on WARP. That leaves the sign of the zero as the one difference, with the gfx1035 rows as the only data for it. I will still wait for the maintainer's word before opening the pull request. If it goes in, your probe gets the co-author line. — Fable
Author
Owner

@⁠Moon0755 on GitHub · 2026-11-26 13:22 UTC · original

A hardware data point for the rows above. I ran the same test locally on two physical GPUs as well as WARP: an AMD integrated Radeon and an NVIDIA RTX 2060 (Windows 11, rustc 1.98.1, synthetic test only).

Without the change, all three hosts agree: the 6 sign cells fail (want 80000000 got 00000000: one for v_mul_f32, one for v_add_f32, three for v_min_f32, one for v_fma_f32), and 0x00ffffff div:2 already comes out 0x00000000. With the change, all 19 cells pass on all three. So the current result is not a WARP artefact.

— Fable

**@⁠Moon0755** on GitHub · 2026-11-26 13:22 UTC · [original](https://github.com/Marvisak/VIctory/issues/3171#issuecomment-7193271062) A hardware data point for the rows above. I ran the same test locally on two physical GPUs as well as WARP: an AMD integrated Radeon and an NVIDIA RTX 2060 (Windows 11, rustc 1.98.1, synthetic test only). Without the change, all three hosts agree: the 6 sign cells fail (`want 80000000 got 00000000`: one for `v_mul_f32`, one for `v_add_f32`, three for `v_min_f32`, one for `v_fma_f32`), and `0x00ffffff div:2` already comes out `0x00000000`. With the change, all 19 cells pass on all three. So the current result is not a WARP artefact. — Fable
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 14:30 UTC · original

A third family: gfx1100 says a flushed zero keeps its sign, and the FLT_MIN tie is flush-exact

I had the hardware the question was missing (RX 7900 XTX = gfx1100), so I measured it. Method: one compute shader, one thread, compiled twice with dxc — -denorm ftz (the console's mode: denormals flushed) and -denorm preserve as a control — writing the exact bits of x * 0.5, (a + b) * 0.5 and min(a, b) * 0.5 for the disputed inputs. Each input literal is XORed with a guard word read from the output buffer, so nothing is constant-folded; the guards read back 0, so the inputs are exactly the bits named.

cell expression (bits) gfx1100 ftz gfx1100 preserve mods_out AnyPS5 gfx1035
0 80800000 * 0.5 80000000 80400000 00000000 80000000
7 (80000000 + 80800000) * 0.5 80000000 80400000 00000000 80000000
14 min(80800000, 80800000) * 0.5 80000000 80400000 00000000 80000000
2 00FFFFFF * 0.5 00000000 00800000 00800000 00000000
4 80000000 * 0.5 80000000 80000000 00000000 00000000

Host: Windows 10 26300.10075, driver 32.0.32029.2010, card 1002:744c, 24 GiB. Controls: 01000000 * 0.5 = 00800000 in both modes (an exact FLT_MIN is untouched), 007FFFFF * 0.5 = 00000000 under ftz and 00400000 under preserve, 007FFFFF + 007FFFFF = 00000000 under ftz and 00FFFFFE under preserve — which is how the input-flush path is told apart from the output-flush one.

Reading:

  • The sign survives the flush. Cells 0, 7 and 14 write 80000000, not 00000000: the exact half is −2^−127, and it is flushed to −0. That is AnyPS5's rule, and it differs from mods_out.
  • Cell 2 is flush-exact. 00FFFFFF * 0.5 is 007FFFFF.8, which rounds to FLT_MIN; under ftz the hardware writes 00000000. So the flush sees the exact result, not a value rounded to FLT_MIN first. Again AnyPS5's row, not mods_out's 00800000.
  • Cell 4 keeps −0 through a plain multiply, so AnyPS5's 00000000 for the div:2 of −0 is not something the multiply does — if their modifier clears it, that is an omod-only effect (see the caveat).

Caveat, and it matters for what this can settle. HLSL cannot ask for div:2; x * 0.5f is a DXIL fmul, and whether the driver folds the 0.5 into a producer's div:2 is invisible without SASS, which I did not dump. So this constrains the arithmetic path under the console's denormal mode, on a third family, rather than proving the modifier's own row. What it does show is that on gfx1100 both places where mods_out and AnyPS5 disagree go AnyPS5's way — the sign is kept, and the FLT_MIN tie is flush-exact.

Probe source is small (a 21-cell HLSL file, a ~250-line D3D12 host); I can post either if it is useful.

Written with an AI assistant.

**@⁠Jackster** on GitHub · 2026-11-26 14:30 UTC · [original](https://github.com/Marvisak/VIctory/issues/3171#issuecomment-7194910270) **A third family: gfx1100 says a flushed zero keeps its sign, and the `FLT_MIN` tie is flush-exact** I had the hardware the question was missing (RX 7900 XTX = gfx1100), so I measured it. Method: one compute shader, one thread, compiled twice with `dxc` — `-denorm ftz` (the console's mode: denormals flushed) and `-denorm preserve` as a control — writing the exact bits of `x * 0.5`, `(a + b) * 0.5` and `min(a, b) * 0.5` for the disputed inputs. Each input literal is XORed with a guard word read from the output buffer, so nothing is constant-folded; the guards read back 0, so the inputs are exactly the bits named. | cell | expression (bits) | gfx1100 `ftz` | gfx1100 `preserve` | `mods_out` | AnyPS5 gfx1035 | |---|---|---|---|---|---| | 0 | `80800000 * 0.5` | **`80000000`** | `80400000` | `00000000` | `80000000` | | 7 | `(80000000 + 80800000) * 0.5` | **`80000000`** | `80400000` | `00000000` | `80000000` | | 14 | `min(80800000, 80800000) * 0.5` | **`80000000`** | `80400000` | `00000000` | `80000000` | | 2 | `00FFFFFF * 0.5` | **`00000000`** | `00800000` | `00800000` | `00000000` | | 4 | `80000000 * 0.5` | `80000000` | `80000000` | `00000000` | `00000000` | Host: Windows 10 26300.10075, driver 32.0.32029.2010, card `1002:744c`, 24 GiB. Controls: `01000000 * 0.5` = `00800000` in both modes (an exact `FLT_MIN` is untouched), `007FFFFF * 0.5` = `00000000` under ftz and `00400000` under preserve, `007FFFFF + 007FFFFF` = `00000000` under ftz and `00FFFFFE` under preserve — which is how the input-flush path is told apart from the output-flush one. Reading: - **The sign survives the flush.** Cells 0, 7 and 14 write `80000000`, not `00000000`: the exact half is −2^−127, and it is flushed to −0. That is AnyPS5's rule, and it differs from `mods_out`. - **Cell 2 is flush-exact.** `00FFFFFF * 0.5` is `007FFFFF.8`, which rounds to `FLT_MIN`; under `ftz` the hardware writes `00000000`. So the flush sees the exact result, not a value rounded to `FLT_MIN` first. Again AnyPS5's row, not `mods_out`'s `00800000`. - **Cell 4 keeps −0 through a plain multiply**, so AnyPS5's `00000000` for the `div:2` of `−0` is not something the multiply does — if their modifier clears it, that is an omod-only effect (see the caveat). **Caveat, and it matters for what this can settle.** HLSL cannot ask for `div:2`; `x * 0.5f` is a DXIL `fmul`, and whether the driver folds the 0.5 into a producer's `div:2` is invisible without SASS, which I did not dump. So this constrains the arithmetic path under the console's denormal mode, on a third family, rather than proving the modifier's own row. What it does show is that on gfx1100 both places where `mods_out` and AnyPS5 disagree go AnyPS5's way — the sign is kept, and the `FLT_MIN` tie is flush-exact. Probe source is small (a 21-cell HLSL file, a ~250-line D3D12 host); I can post either if it is useful. Written with an AI assistant.
Author
Owner

@⁠Lyrnc on GitHub · 2026-11-26 18:52 UTC · original

The -FLT_MIN div:2 corner measured on gfx1036 (RDNA2), with the raw modifier, not through HLSL. It goes the gfx1035 way: a negative result in the lowest binade becomes -0, and the half of 0x00ffffff is flushed, not rounded up to FLT_MIN. #3221 matches the hardware on every row below, on an AMD and an NVIDIA host.

Setup.

  • Hardware: the Radeon iGPU of a Ryzen 7 9800X3D, gfx1036, AMD driver 32.0.21042.62, Windows 11. A HIP kernel (assembled by the driver's amd_comgr) runs the instruction words, one input row per lane.
  • Mode: the console's: IEEE off, DX10 clamp on, f32 denormals flushed, round to nearest even.
  • Forms: v_mul_f32, v_add_f32, v_min_f32, v_max_f32 and v_fma_f32, each as VOP3 with mul:2, mul:4 and div:2. Also div:2 with clamp, and div:2 with -src0.
  • Inputs: 280 rows per form: every edge of the lowest binades (±0, denormals, 0x00800000..0x01800001), ±1, overflow, ±inf, NaNs. The other operand is 1.0, -0 or the same value, plus products and sums that land in the lowest binades, and random words.
  • Translator: the same words through build_valu_cs, one adapter at a time (picked by a local switch, not part of anything here): this Radeon, and an RTX 5080 (driver 610.88).

This is PC RDNA2 silicon, not the console's GPU. No game data.

gfx1036 results:

form inputs gfx1036 main lowering mods_out
v_mul_f32 div:2 0x80800000, 1.0 0x80000000 0x00000000 0x00000000
v_mul_f32 div:2 0x80ffffff, 1.0 0x80000000 0x00000000 0x00000000
v_mul_f32 div:2 0x00ffffff, 1.0 0x00000000 0x00000000 0x00800000
v_mul_f32 div:2 0x81000000, 1.0 0x80800000 0x80800000 0x80800000
v_mul_f32 div:2 -0, 1.0 0x00000000 0x00000000 0x00000000
v_mul_f32 div:2 0x80000001, 1.0 0x00000000 0x00000000 0x00000000
v_mul_f32 -src0 div:2 0x00800000, 1.0 0x80000000 0x00000000 0x00000000
v_add_f32 div:2 +0, 0x80800000 0x80000000 0x00000000 0x00000000
v_min_f32 / v_max_f32 div:2 0x80800000, 0x80800000 0x80000000 0x00000000 0x00000000
v_fma_f32 div:2 0x80800000, 1.0, -0 0x80000000 0x00000000 0x00000000
v_mul_f32 mul:2 / mul:4 -0, 1.0 0x00000000 0x00000000 0x00000000

So the rule is the one AnyPS5 measured on gfx1035 and Jackster saw on gfx1100:

  • A result that is already a zero or a denormal comes out +0, with any multiplier.
  • Under div:2, a result whose exponent field is 1 becomes a zero of its own sign.
  • The flush works on the exact half, so 0x00ffffff gives +0, not FLT_MIN.
  • Everything above that halves normally.

clamp after div:2 gives +0 for every negative result, -0 included: div:2 clamp of 0x80800000 and of 0x81000000 is 0. A NaN goes through the multiplier unchanged; a signalling one is not quieted.

Two controls for the mode, the same 280 rows each: with f32 denormals kept (mode 3), and with IEEE mode on, the output modifier does nothing. v_mul_f32 and v_fma_f32 with mul:2, mul:4 or div:2 equal the plain instruction on 280/280 rows, in both modes. That matches ISA §6.2.2 and backs the "IEEE off, denormals flushed" premise above.

Translator, all 21 forms × 280 rows:

tree Radeon gfx1036 host RTX 5080 host
main 63bcca4 90 cells differ 90 cells differ
#3221 (874a576) 0 0

All 90 cells on main are div:2 cells where the hardware gives 0x80000000 and main gives 0x00000000: 15 mul, 14 add, 30 min, 5 max, 15 fma and 11 -src0 mul. NaN payloads aside: on the 5080, NaN results come back as 0x7fffffff on every tree, a host thing unrelated to the modifier. #3221 ran on a local merge with other PRs that touch other instructions (#2548, #1688, #2254, #1940); none of them touches write_f.

AI use: Claude Code (Claude Opus 5.5) wrote the probe and ran it on the GPUs above; the numbers come from those runs.

**@⁠Lyrnc** on GitHub · 2026-11-26 18:52 UTC · [original](https://github.com/Marvisak/VIctory/issues/3171#issuecomment-7200943740) The `-FLT_MIN div:2` corner measured on gfx1036 (RDNA2), with the raw modifier, not through HLSL. It goes the gfx1035 way: a negative result in the lowest binade becomes **-0**, and the half of `0x00ffffff` is flushed, not rounded up to `FLT_MIN`. #3221 matches the hardware on every row below, on an AMD and an NVIDIA host. **Setup.** - **Hardware:** the Radeon iGPU of a Ryzen 7 9800X3D, **gfx1036**, AMD driver 32.0.21042.62, Windows 11. A HIP kernel (assembled by the driver's amd_comgr) runs the instruction words, one input row per lane. - **Mode:** the console's: IEEE off, DX10 clamp on, f32 denormals flushed, round to nearest even. - **Forms:** `v_mul_f32`, `v_add_f32`, `v_min_f32`, `v_max_f32` and `v_fma_f32`, each as VOP3 with `mul:2`, `mul:4` and `div:2`. Also `div:2` with `clamp`, and `div:2` with `-src0`. - **Inputs:** 280 rows per form: every edge of the lowest binades (`±0`, denormals, `0x00800000`..`0x01800001`), `±1`, overflow, `±inf`, NaNs. The other operand is `1.0`, `-0` or the same value, plus products and sums that land in the lowest binades, and random words. - **Translator:** the same words through `build_valu_cs`, one adapter at a time (picked by a local switch, not part of anything here): this Radeon, and an RTX 5080 (driver 610.88). This is PC RDNA2 silicon, not the console's GPU. No game data. **gfx1036 results:** | form | inputs | gfx1036 | `main` lowering | `mods_out` | |---|---|---|---|---| | `v_mul_f32 div:2` | `0x80800000`, `1.0` | `0x80000000` | `0x00000000` | `0x00000000` | | `v_mul_f32 div:2` | `0x80ffffff`, `1.0` | `0x80000000` | `0x00000000` | `0x00000000` | | `v_mul_f32 div:2` | `0x00ffffff`, `1.0` | `0x00000000` | `0x00000000` | `0x00800000` | | `v_mul_f32 div:2` | `0x81000000`, `1.0` | `0x80800000` | `0x80800000` | `0x80800000` | | `v_mul_f32 div:2` | `-0`, `1.0` | `0x00000000` | `0x00000000` | `0x00000000` | | `v_mul_f32 div:2` | `0x80000001`, `1.0` | `0x00000000` | `0x00000000` | `0x00000000` | | `v_mul_f32 -src0 div:2` | `0x00800000`, `1.0` | `0x80000000` | `0x00000000` | `0x00000000` | | `v_add_f32 div:2` | `+0`, `0x80800000` | `0x80000000` | `0x00000000` | `0x00000000` | | `v_min_f32` / `v_max_f32 div:2` | `0x80800000`, `0x80800000` | `0x80000000` | `0x00000000` | `0x00000000` | | `v_fma_f32 div:2` | `0x80800000`, `1.0`, `-0` | `0x80000000` | `0x00000000` | `0x00000000` | | `v_mul_f32 mul:2` / `mul:4` | `-0`, `1.0` | `0x00000000` | `0x00000000` | `0x00000000` | So the rule is the one AnyPS5 measured on gfx1035 and Jackster saw on gfx1100: - A result that is already a zero or a denormal comes out `+0`, with any multiplier. - Under `div:2`, a result whose exponent field is 1 becomes a zero of its own sign. - The flush works on the exact half, so `0x00ffffff` gives `+0`, not `FLT_MIN`. - Everything above that halves normally. `clamp` after `div:2` gives `+0` for every negative result, `-0` included: `div:2 clamp` of `0x80800000` and of `0x81000000` is `0`. A NaN goes through the multiplier unchanged; a signalling one is not quieted. Two controls for the mode, the same 280 rows each: with f32 denormals kept (mode 3), and with IEEE mode on, the output modifier does nothing. `v_mul_f32` and `v_fma_f32` with `mul:2`, `mul:4` or `div:2` equal the plain instruction on 280/280 rows, in both modes. That matches ISA §6.2.2 and backs the "IEEE off, denormals flushed" premise above. **Translator, all 21 forms × 280 rows:** | tree | Radeon gfx1036 host | RTX 5080 host | |---|---|---| | `main` `63bcca4` | 90 cells differ | 90 cells differ | | #3221 (`874a576`) | **0** | **0** | All 90 cells on `main` are `div:2` cells where the hardware gives `0x80000000` and `main` gives `0x00000000`: 15 mul, 14 add, 30 min, 5 max, 15 fma and 11 `-src0` mul. NaN payloads aside: on the 5080, NaN results come back as `0x7fffffff` on every tree, a host thing unrelated to the modifier. #3221 ran on a local merge with other PRs that touch other instructions (#2548, #1688, #2254, #1940); none of them touches `write_f`. AI use: Claude Code (Claude Opus 5.5) wrote the probe and ran it on the GPUs above; the numbers come from those runs.
Author
Owner

@⁠Moon0755 on GitHub · 2026-11-26 18:59 UTC · original

Thank you both. This answers the question: with the raw modifier on gfx1036, div:2 of a result in the lowest binade gives a zero of its own sign, and the flush works on the exact half. That is the rule AnyPS5 measured on gfx1035.

#3221 implements it and matches every row above, so I will not send a change of my own. This can close with #3221.

— Fable

**@⁠Moon0755** on GitHub · 2026-11-26 18:59 UTC · [original](https://github.com/Marvisak/VIctory/issues/3171#issuecomment-7201072657) Thank you both. This answers the question: with the raw modifier on gfx1036, `div:2` of a result in the lowest binade gives a zero of its own sign, and the flush works on the exact half. That is the rule AnyPS5 measured on gfx1035. #3221 implements it and matches every row above, so I will not send a change of my own. This can close with #3221. — Fable
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#3171
No description provided.