pixel_aot: non-packed binary16 VOP1/VOP2 ALU under the low-16-only contract (scope question) #833

Open
opened 2026-11-23 11:00:07 +00:00 by JB2WIN · 17 comments
JB2WIN commented 2026-11-23 11:00:07 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-23T11:00:07Z.


On current main, a form-coverage run lists the non-packed binary16 ALU forms as uncovered:

  • VOP2: v_add_f16, v_sub_f16, v_subrev_f16, v_mul_f16, v_min_f16, v_max_f16, v_ldexp_f16, v_fmac_f16, v_fmaak_f16 and v_fmamk_f16.
  • VOP1: v_rcp_f16, v_sqrt_f16, v_rsq_f16, v_log_f16, v_exp_f16, v_sin_f16, v_cos_f16, v_floor_f16, v_ceil_f16, v_trunc_f16, v_rndne_f16 and v_fract_f16.
  • VOP3: the _e64 spellings of the above.

#732 now gives the 16-bit integer ops a low-16-only contract. A first slice of these forms could use the same contract:

  • The result is tracked as a defined low half.
  • Readers are restricted to those that read only bits 15:0, such as v_cvt_f32_f16, the f16 compares and SDWA WORD_0.
  • A whole-word or high-half reader is refused.

Before proposing a design I'd like to settle three points:

  1. Scope. Is the low-16-only contract acceptable for binary16 results as well? Would you prefer the reader set to start with only v_cvt_f32_f16 plus SDWA WORD_0?
  2. Overlap. #419 lowers DPP binary16 ops and #704 lowers v_fma_f16. @KomaGuy and @Holastor, would a plain VOP1/VOP2 slice get in your way, or should it wait for those PRs?
  3. Rounding and denormals. Should the first slice accept only the default MODE (round to nearest even, binary16 denormals preserved) and refuse the other modes, as the existing f16 paths do under HALF_ROUNDING?

I'd start with the arithmetic VOP2 set (add/sub/subrev/mul/min/max). Transcendental and ldexp would come later, if at all. AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6557774000 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T11:00:07Z. --- On current `main`, a form-coverage run lists the non-packed binary16 ALU forms as uncovered: - **VOP2:** `v_add_f16`, `v_sub_f16`, `v_subrev_f16`, `v_mul_f16`, `v_min_f16`, `v_max_f16`, `v_ldexp_f16`, `v_fmac_f16`, `v_fmaak_f16` and `v_fmamk_f16`. - **VOP1:** `v_rcp_f16`, `v_sqrt_f16`, `v_rsq_f16`, `v_log_f16`, `v_exp_f16`, `v_sin_f16`, `v_cos_f16`, `v_floor_f16`, `v_ceil_f16`, `v_trunc_f16`, `v_rndne_f16` and `v_fract_f16`. - **VOP3:** the `_e64` spellings of the above. #732 now gives the 16-bit integer ops a low-16-only contract. A first slice of these forms could use the same contract: - The result is tracked as a defined low half. - Readers are restricted to those that read only bits 15:0, such as `v_cvt_f32_f16`, the f16 compares and SDWA `WORD_0`. - A whole-word or high-half reader is refused. Before proposing a design I'd like to settle three points: 1. **Scope.** Is the low-16-only contract acceptable for binary16 results as well? Would you prefer the reader set to start with only `v_cvt_f32_f16` plus SDWA `WORD_0`? 2. **Overlap.** #419 lowers DPP binary16 ops and #704 lowers `v_fma_f16`. @KomaGuy and @Holastor, would a plain VOP1/VOP2 slice get in your way, or should it wait for those PRs? 3. **Rounding and denormals.** Should the first slice accept only the default MODE (round to nearest even, binary16 denormals preserved) and refuse the other modes, as the existing f16 paths do under `HALF_ROUNDING`? I'd start with the arithmetic VOP2 set (`add`/`sub`/`subrev`/`mul`/`min`/`max`). Transcendental and `ldexp` would come later, if at all. AI-assisted (Claude Code).
Holastor commented 2026-11-24 06:49:08 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T11:05:50Z.


Thanks for checking in @JB2WIN!

A plain VOP1/VOP2 slice for binary16 arithmetic will not get in the way of #704:

  • #704 handles 3-operand VOP3 _fma_f16 and _div_fmas_f32 (and explicitly rejects _div_scale_f32). It does not define or modify the VOP1/VOP2 2-operand float16 tables.
  • #704 is rebased onto latest main, all review feedback from R0Y00 has been addressed, and it's currently awaiting final maintainer merge.

Regarding your 3rd point (rounding modes): in #704, R0Y00 specifically requested rejecting non-default rounding modes (HALF_ROUNDING["0"] / RNE only, rejecting HALF_RTZ), so sticking to the default RNE mode for the first slice is definitely consistent with established practice in pixel_aot.

Feel free to proceed with the VOP2 arithmetic slice (dd/sub/subrev/mul/min/max)!

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7099032913 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7099032913). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T11:05:50Z. --- Thanks for checking in @JB2WIN! A plain VOP1/VOP2 slice for binary16 arithmetic will **not** get in the way of #704: - #704 handles 3-operand VOP3 _fma_f16 and _div_fmas_f32 (and explicitly rejects _div_scale_f32). It does not define or modify the VOP1/VOP2 2-operand float16 tables. - #704 is rebased onto latest main, all review feedback from R0Y00 has been addressed, and it's currently awaiting final maintainer merge. Regarding your 3rd point (rounding modes): in #704, R0Y00 specifically requested rejecting non-default rounding modes (HALF_ROUNDING["0"] / RNE only, rejecting HALF_RTZ), so sticking to the default RNE mode for the first slice is definitely consistent with established practice in pixel_aot. Feel free to proceed with the VOP2 arithmetic slice (dd/sub/subrev/mul/min/max)!
R0Y00 commented 2026-11-24 06:49:08 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T11:16:39Z.


A small plain, non-fused VOP2 slice can proceed independently of #419 and #704. Start with add/sub/subrev/mul under a validated binary16 mode: nearest-even with half denormals preserved. A numeric half-mode assumption needs the same entry provenance or tracked MODE write as the rest of the profile; refuse unsupported or unknown modes. Track the low half as defined, with the high half unknown. Start with audited v_cvt_f32_f16 and SDWA WORD_0 consumers. Any added compare/chained consumer needs its own low-half validation; keep whole-word and high-half readers rejected. Keep min/max separate until the signed-zero and NaN rules are pinned. Use LLVM 15 round-trip and a lossless integer readback with halfway rounding, positive and negative subnormals, signed zero, and a wrong-rounding/high-half control. For any input class whose observable result is not established, require a proven supported value or independent native reference before extending the profile.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7099359788 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7099359788). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T11:16:39Z. --- A small plain, non-fused VOP2 slice can proceed independently of #419 and #704. Start with add/sub/subrev/mul under a validated binary16 mode: nearest-even with half denormals preserved. A numeric half-mode assumption needs the same entry provenance or tracked MODE write as the rest of the profile; refuse unsupported or unknown modes. Track the low half as defined, with the high half unknown. Start with audited `v_cvt_f32_f16` and SDWA `WORD_0` consumers. Any added compare/chained consumer needs its own low-half validation; keep whole-word and high-half readers rejected. Keep min/max separate until the signed-zero and NaN rules are pinned. Use LLVM 15 round-trip and a lossless integer readback with halfway rounding, positive and negative subnormals, signed zero, and a wrong-rounding/high-half control. For any input class whose observable result is not established, require a proven supported value or independent native reference before extending the profile.
JB2WIN commented 2026-11-24 06:49:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-23T12:08:52Z.


Thanks, both. The design for the add/sub/subrev/mul slice is drafted. Before I build it, two choices are yours.

The arithmetic is widen16 of both low halves, one precise binary32 operation, then narrow16. That is exact for these ops: binary32 mul of two halves is exact, and double rounding through binary32 is harmless for add because 24 ≥ 2·11+2. I checked it exhaustively offline over all finite operand pairs for add and mul, with 0 differences.

  1. Inputs whose result isn't established (NaN, ±inf, overflow). Which do you want?
    • (a) Default: refuse statically known NaN/inf operands at translation. Claim and draw only finite inputs, and document runtime NaN/inf as outside the profile.
    • (b) Strict, like require_proven_i32_f32_range: refuse any source not statically proven finite. That makes the slice much narrower.
  2. Denormal-mode provenance. Rounding is already tracked through MODE writes. For binary16 denormals the plan is a named entry assumption (HALF_DENORM_ENTRY = preserve), with every MODE-changing instruction refused. Is that the provenance you mean, or do you want a tracked hwreg(HW_REG_MODE, 6, 2) write?

Smaller choices, unless you object:

  • The result gets its own ("half16", …) tag, separate from integer low16, so the integer 16-bit readers can't consume it.
  • Readers are v_cvt_f32_f16 without modifiers, plus SDWA WORD_0 (cvt and mov).
  • Modifiers, clamp, omod and integer inline constants other than 0 are refused.
  • The existing v_add_f16_e64 refusal neighbour becomes v_min_f16_e64.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7100560711 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7100560711). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T12:08:52Z. --- Thanks, both. The design for the `add`/`sub`/`subrev`/`mul` slice is drafted. Before I build it, two choices are yours. The arithmetic is `widen16` of both low halves, one `precise` binary32 operation, then `narrow16`. That is exact for these ops: binary32 `mul` of two halves is exact, and double rounding through binary32 is harmless for `add` because 24 ≥ 2·11+2. I checked it exhaustively offline over all finite operand pairs for `add` and `mul`, with 0 differences. 1. **Inputs whose result isn't established (NaN, ±inf, overflow).** Which do you want? - **(a) Default:** refuse statically known NaN/inf operands at translation. Claim and draw only finite inputs, and document runtime NaN/inf as outside the profile. - **(b) Strict, like `require_proven_i32_f32_range`:** refuse any source not statically proven finite. That makes the slice much narrower. 2. **Denormal-mode provenance.** Rounding is already tracked through MODE writes. For binary16 denormals the plan is a named entry assumption (`HALF_DENORM_ENTRY` = preserve), with every MODE-changing instruction refused. Is that the provenance you mean, or do you want a tracked `hwreg(HW_REG_MODE, 6, 2)` write? Smaller choices, unless you object: - The result gets its own `("half16", …)` tag, separate from integer `low16`, so the integer 16-bit readers can't consume it. - Readers are `v_cvt_f32_f16` without modifiers, plus SDWA `WORD_0` (cvt and mov). - Modifiers, `clamp`, omod and integer inline constants other than 0 are refused. - The existing `v_add_f16_e64` refusal neighbour becomes `v_min_f16_e64`.
R0Y00 commented 2026-11-24 06:49:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T12:15:41Z.


Choose (b) for the first slice. Require both operands to be proven finite, including register copies with established provenance. Leave arbitrary runtime operands for the extension that establishes NaN and infinity behavior. Finite overflow is a separate case. If the slice accepts it, pin the signed result at both overflow boundaries with an independent reference and integer readback. Otherwise require a result within the supported range.

An explicit entry profile is sufficient for binary16 denormal preservation when the caller gets it from validated guest state. Keep the new forms unavailable when that entry state is unknown, and refuse MODE writes that might invalidate it. Tracking the denormal field can follow separately. The distinct half16 tag and the proposed audited readers fit the low-half rule. Please include a refusal for an unknown mode and for a dynamic operand lacking the finite proof. Keep the signed-zero and subnormal cases in the draw.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7100753905 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7100753905). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T12:15:41Z. --- Choose (b) for the first slice. Require both operands to be proven finite, including register copies with established provenance. Leave arbitrary runtime operands for the extension that establishes NaN and infinity behavior. Finite overflow is a separate case. If the slice accepts it, pin the signed result at both overflow boundaries with an independent reference and integer readback. Otherwise require a result within the supported range. An explicit entry profile is sufficient for binary16 denormal preservation when the caller gets it from validated guest state. Keep the new forms unavailable when that entry state is unknown, and refuse MODE writes that might invalidate it. Tracking the denormal field can follow separately. The distinct half16 tag and the proposed audited readers fit the low-half rule. Please include a refusal for an unknown mode and for a dynamic operand lacking the finite proof. Keep the signed-zero and subnormal cases in the draw.
R0Y00 commented 2026-11-24 06:49:11 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T14:09:01Z.


#854 landed the first slice: plain add, sub, subrev and mul on proven-finite low halves under the validated binary16 mode. WARP and RTX reads matched, including signed overflow, and the high-half consumption controls still refuse unsupported uses. This issue stays open for the remaining forms and arbitrary runtime operands.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7103555012 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7103555012). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T14:09:01Z. --- #854 landed the first slice: plain add, sub, subrev and mul on proven-finite low halves under the validated binary16 mode. WARP and RTX reads matched, including signed overflow, and the high-half consumption controls still refuse unsupported uses. This issue stays open for the remaining forms and arbitrary runtime operands.
JB2WIN commented 2026-11-24 06:49:12 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-23T14:53:40Z.


Thanks for landing #854. I'd like to take the next small slice under the same rules: v_floor_f16, v_ceil_f16, v_trunc_f16 and v_rndne_f16 (VOP1 and _e64). LLVM 15.0.7 VOP1Instructions.td L449-452 maps them to ffloor, fceil, ftrunc and frint.

The plan:

  • Operands: the operand must be proven finite, under the explicit denormal entry profile.
  • Lowering: widen16, then the binary32 floor/ceil/trunc/round, then narrow16. The rounded value of a finite half is itself a representable half, so the narrowing is exact.
  • Result: a half16 result read only by the audited readers.
  • Refused: clamp, omod and modifiers.
  • Draw: integer readback covering ±0, negative values that round to -0 (for example trunc(-0.5)), halfway cases for rndne (0.5, 1.5, 2.5 and -2.5), the largest finite values, subnormals and integers at 1024 and above. Mutations swap each op for another and drop the sign of a -0 result.

v_fract_f16 stays out because of its clamp near 1, and so do min/max and the transcendentals. AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7104698296 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7104698296). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T14:53:40Z. --- Thanks for landing #854. I'd like to take the next small slice under the same rules: `v_floor_f16`, `v_ceil_f16`, `v_trunc_f16` and `v_rndne_f16` (VOP1 and `_e64`). LLVM 15.0.7 `VOP1Instructions.td` L449-452 maps them to `ffloor`, `fceil`, `ftrunc` and `frint`. The plan: - **Operands:** the operand must be proven finite, under the explicit denormal entry profile. - **Lowering:** `widen16`, then the binary32 `floor`/`ceil`/`trunc`/`round`, then `narrow16`. The rounded value of a finite half is itself a representable half, so the narrowing is exact. - **Result:** a `half16` result read only by the audited readers. - **Refused:** `clamp`, omod and modifiers. - **Draw:** integer readback covering ±0, negative values that round to -0 (for example `trunc(-0.5)`), halfway cases for `rndne` (0.5, 1.5, 2.5 and -2.5), the largest finite values, subnormals and integers at 1024 and above. Mutations swap each op for another and drop the sign of a -0 result. `v_fract_f16` stays out because of its clamp near 1, and so do `min`/`max` and the transcendentals. AI-assisted (Claude Code).
R0Y00 commented 2026-11-24 06:49:12 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T14:54:48Z.


Please go ahead with the four rounding operations under the same finite-input, explicit binary16 mode and low-half-only rules as #854. Keep the existing _e32 and _e64 modifier refusals. For RNDNE, verify ties-to-even with the emitted code. For signed zero, read back the raw half bits and preserve the input sign when a result rounds to zero. Include negative subnormals: FLOOR should give -1, while CEIL and TRUNC should give -0. The positive counterpart distinguishes CEIL from TRUNC. The existing consumer and half-width rejection controls still apply.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7104726695 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7104726695). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T14:54:48Z. --- Please go ahead with the four rounding operations under the same finite-input, explicit binary16 mode and low-half-only rules as #854. Keep the existing _e32 and _e64 modifier refusals. For RNDNE, verify ties-to-even with the emitted code. For signed zero, read back the raw half bits and preserve the input sign when a result rounds to zero. Include negative subnormals: FLOOR should give -1, while CEIL and TRUNC should give -0. The positive counterpart distinguishes CEIL from TRUNC. The existing consumer and half-width rejection controls still apply.
R0Y00 commented 2026-11-24 06:49:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T15:44:15Z.


#881 merged at b8646f5. The finite, low-half FLOOR, CEIL, TRUNC and RNDNE forms now have integer pixel readbacks and passed on WARP and RTX. All five mutations, including ties-away and lost negative zero, differed on both. The out-of-scope forms and arbitrary runtime inputs still need separate evidence, so this stays open.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7106029922 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7106029922). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T15:44:15Z. --- #881 merged at `b8646f5`. The finite, low-half FLOOR, CEIL, TRUNC and RNDNE forms now have integer pixel readbacks and passed on WARP and RTX. All five mutations, including ties-away and lost negative zero, differed on both. The out-of-scope forms and arbitrary runtime inputs still need separate evidence, so this stays open.
JB2WIN commented 2026-11-24 06:49:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-23T15:53:05Z.


Thanks for landing #881. Here is a proposal for the next slice; I won't start it without your go-ahead.

The candidates are v_cvt_f16_i16 and v_cvt_f16_u16 (VOP1 and _e64). LLVM 15.0.7 VOP1Instructions.td L432-433 maps them to sint_to_fp and uint_to_fp. The integer input class differs from the float slices:

  • v_cvt_f16_i16: every i16 input (−32768…32767) converts to a finite binary16 under nearest-even. No NaN or inf can arise, and the largest magnitude, 32768, is representable. So a runtime source could be accepted, as long as it is a value the existing 16-bit integer contract already reads correctly: a low16 result, or a register whose low 16 bits are read.
  • v_cvt_f16_u16: inputs ≥ 65520 round to +inf. The source would therefore need a proof that its value is below 65520, and runtime values would be refused. The alternative is to pin the overflow at the boundary, but you set that up as a separate case.

Either way the result would be a half16 low half for the audited readers. clamp and omod are refused, under the explicit denormal entry profile. Integers above 2048 still round, so the draw would include halfway integers such as 2049 and 4099, ±32768, -0 versus +0 (the integer 0 gives +0), and the boundary 65519/65520 for u16.

Would you accept runtime i16 sources for v_cvt_f16_i16, or keep both conversions on proven-constant sources for now? AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7106262399 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7106262399). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T15:53:05Z. --- Thanks for landing #881. Here is a proposal for the next slice; I won't start it without your go-ahead. The candidates are `v_cvt_f16_i16` and `v_cvt_f16_u16` (VOP1 and `_e64`). LLVM 15.0.7 `VOP1Instructions.td` L432-433 maps them to `sint_to_fp` and `uint_to_fp`. The integer input class differs from the float slices: - **`v_cvt_f16_i16`:** every i16 input (−32768…32767) converts to a finite binary16 under nearest-even. No NaN or inf can arise, and the largest magnitude, 32768, is representable. So a runtime source could be accepted, as long as it is a value the existing 16-bit integer contract already reads correctly: a `low16` result, or a register whose low 16 bits are read. - **`v_cvt_f16_u16`:** inputs ≥ 65520 round to +inf. The source would therefore need a proof that its value is below 65520, and runtime values would be refused. The alternative is to pin the overflow at the boundary, but you set that up as a separate case. Either way the result would be a `half16` low half for the audited readers. `clamp` and omod are refused, under the explicit denormal entry profile. Integers above 2048 still round, so the draw would include halfway integers such as 2049 and 4099, ±32768, -0 versus +0 (the integer 0 gives +0), and the boundary 65519/65520 for u16. Would you accept runtime i16 sources for `v_cvt_f16_i16`, or keep both conversions on proven-constant sources for now? AI-assisted (Claude Code).
R0Y00 commented 2026-11-24 06:49:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T16:04:05Z.


Please go ahead with runtime signed i16 through the existing audited low-16 integer reader. It must sign-extend bits 15:0, and the result stays a low-half-only binary16 value. All signed i16 inputs round to finite binary16 under the stated mode, so a constant proof is unnecessary. For u16, keep the current scope to statically proven values below 65520; reject an unproven runtime source and the overflow boundary. Keep modifiers refused.

For signed runtime cases, send distinct values through the same compiled shader and vary the high half independently. Include -32768, 32767, 2049 and its negative, and integer zero (expected +0). For unsigned constants, 65519 should round to 65504 and 65520 should be refused. Use raw-bit readback and a mutation that would catch a zero-extension or ties-away implementation.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7106555208 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7106555208). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T16:04:05Z. --- Please go ahead with runtime signed i16 through the existing audited low-16 integer reader. It must sign-extend bits 15:0, and the result stays a low-half-only binary16 value. All signed i16 inputs round to finite binary16 under the stated mode, so a constant proof is unnecessary. For u16, keep the current scope to statically proven values below 65520; reject an unproven runtime source and the overflow boundary. Keep modifiers refused. For signed runtime cases, send distinct values through the same compiled shader and vary the high half independently. Include -32768, 32767, 2049 and its negative, and integer zero (expected +0). For unsigned constants, 65519 should round to 65504 and 65520 should be refused. Use raw-bit readback and a mutation that would catch a zero-extension or ties-away implementation.
KomaGuy commented 2026-11-24 06:49:35 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-23T19:52:37Z.


Thanks for checking @JB2WIN! Neither #419 (DPP binary16 ops) nor #421 (DPP conversions) overlaps with plain VOP1/VOP2 binary16 forms — glad #881 landed and feel free to proceed with the next plain slice.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112233992 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7112233992). Originally posted by [KomaGuy](https://github.com/KomaGuy) on 2026-11-23T19:52:37Z. --- Thanks for checking @JB2WIN! Neither #419 (DPP binary16 ops) nor #421 (DPP conversions) overlaps with plain VOP1/VOP2 binary16 forms — glad #881 landed and feel free to proceed with the next plain slice.
JB2WIN commented 2026-11-24 06:49:35 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-23T19:52:52Z.


Thanks for landing #921. Here is a proposal for the reverse direction. I'll wait for your go-ahead before starting it.

The forms are v_cvt_i16_f16 and v_cvt_u16_f16, plain and _e64. LLVM 15.0.7 VOP1Instructions.td L436-437 maps them to fp_to_sint and fp_to_uint (VOP_I16_F16_SPECIAL_OMOD), which truncate toward zero. Under the existing rules, the slice would be:

  • Inputs: only proven-finite half sources whose truncated value lies in the destination range. For i16 that is -32768…32767. For u16 it is 0…65535, and inputs in (-1, 0) truncate to 0. A runtime source would be refused, and so would an out-of-range constant, because saturation and the NaN/inf behaviour are not established.
  • Result: a low16 integer value, readable through the audited 16-bit integer readers from #732. The bits are the low 16 bits of the truncated integer.
  • Refused: modifiers, clamp and omod.
  • Draw coverage: ±0, -0.5 → 0, ±1.5 → ±1, ±32767.5, 32768 for u16, 65504 for u16, a subnormal → 0, and the largest in-range negative values.
  • Mutations: round to nearest instead of truncation, a sign error, and a high-half read.

Should this slice stay on proven in-range constants, or do you want a different first step for half→int? AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112240512 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7112240512). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T19:52:52Z. --- Thanks for landing #921. Here is a proposal for the reverse direction. I'll wait for your go-ahead before starting it. The forms are `v_cvt_i16_f16` and `v_cvt_u16_f16`, plain and `_e64`. LLVM 15.0.7 `VOP1Instructions.td` L436-437 maps them to `fp_to_sint` and `fp_to_uint` (`VOP_I16_F16_SPECIAL_OMOD`), which truncate toward zero. Under the existing rules, the slice would be: - **Inputs:** only proven-finite half sources whose truncated value lies in the destination range. For i16 that is -32768…32767. For u16 it is 0…65535, and inputs in (-1, 0) truncate to 0. A runtime source would be refused, and so would an out-of-range constant, because saturation and the NaN/inf behaviour are not established. - **Result:** a `low16` integer value, readable through the audited 16-bit integer readers from #732. The bits are the low 16 bits of the truncated integer. - **Refused:** modifiers, `clamp` and omod. - **Draw coverage:** ±0, -0.5 → 0, ±1.5 → ±1, ±32767.5, 32768 for u16, 65504 for u16, a subnormal → 0, and the largest in-range negative values. - **Mutations:** round to nearest instead of truncation, a sign error, and a high-half read. Should this slice stay on proven in-range constants, or do you want a different first step for half→int? AI-assisted (Claude Code).
R0Y00 commented 2026-11-24 06:49:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T20:01:38Z.


Please proceed with the finite, statically proven in-range slice. RDNA 2 §12.8, VOP1 entries 82 and 83, explicitly specifies truncation for both. Apply the range check to the truncated integer, then produce a low16 result and retain the existing high-half refusal. For boundary tests use exactly representable halves: 32752 and 32768 straddle the positive signed limit, and -32768 and its next lower half straddle the negative limit. 32767.5 is not representable as a half. Include -0.5 to unsigned zero, -1 refused for unsigned, 65504 for unsigned, nonfinite/unknown-source refusals, and an independent rounding mutation. Keep modifiers and output modifiers outside this slice. Use LLVM 15 assembly and exact integer readback for plain and e64.

AMD RDNA 2 ISA reference

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112448101 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7112448101). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T20:01:38Z. --- Please proceed with the finite, statically proven in-range slice. RDNA 2 §12.8, VOP1 entries 82 and 83, explicitly specifies truncation for both. Apply the range check to the truncated integer, then produce a low16 result and retain the existing high-half refusal. For boundary tests use exactly representable halves: 32752 and 32768 straddle the positive signed limit, and -32768 and its next lower half straddle the negative limit. 32767.5 is not representable as a half. Include -0.5 to unsigned zero, -1 refused for unsigned, 65504 for unsigned, nonfinite/unknown-source refusals, and an independent rounding mutation. Keep modifiers and output modifiers outside this slice. Use LLVM 15 assembly and exact integer readback for plain and e64. [AMD RDNA 2 ISA reference](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content)
R0Y00 commented 2026-11-24 06:49:57 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T00:35:07Z.


#1077 and #1084 cover the same finite, statically proven binary16-to-i16/u16 low-half conversion slice. @tedin7 and @romn4rch, please use #1077 as the integration point and bring any distinct boundary or mutation controls from #1084 over with attribution. One independent LLVM 15/WARP review of the combined candidate would help. Keep the whole-word/high-half rejection, exact signed and unsigned endpoints, and the controls for nonfinite and out-of-range inputs. The issue remains open while this slice is reviewed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118220857 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7118220857). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T00:35:07Z. --- #1077 and #1084 cover the same finite, statically proven binary16-to-i16/u16 low-half conversion slice. @tedin7 and @romn4rch, please use #1077 as the integration point and bring any distinct boundary or mutation controls from #1084 over with attribution. One independent LLVM 15/WARP review of the combined candidate would help. Keep the whole-word/high-half rejection, exact signed and unsigned endpoints, and the controls for nonfinite and out-of-range inputs. The issue remains open while this slice is reviewed.
romn4rch commented 2026-11-24 06:49:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by romn4rch on 2026-11-24T00:53:04Z.


I compared #1084 with #1077 at e7ab28b to find controls to bring over. Every boundary, refusal and mutation in #1084 already has a counterpart in #1077:

#1084 control In #1077
i16: 32752 (0x77ff) and -32768 (0xf800) accepted; 32768 (0x7800) and -32800 (0xf801) refused same values, same outcome
u16: -0.5 (0xb800) gives 0, 65504 (0x7bff) accepted, -1 (0xbc00) refused same values, same outcome
±1.5, both signed zeros, subnormals 0x0001 and 0x8001 in the i16 and u16 draw tables
infinity, NaN and unproven SGPR/VGPR sources refused refused, with exact messages
missing or invalid binary16 entry state refused
mutations: round to nearest, sign error, source read from bits 31:16 the same three mutations
low-half SDWA reader accepted, other readers refused same reader checks

Nothing needs to move. One behavioural difference: #1084 accepts both forms under round toward zero, treating the truncation as defined by the instruction, while #1077 refuses them like the other binary16 forms. I would keep #1077's refusal for this slice, because nothing here measures whether the MODE rounding field affects these conversions.

I'm closing #1084 in favour of #1077 and will run an independent LLVM 15 and WARP review of #1077.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118534792 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7118534792). Originally posted by [romn4rch](https://github.com/romn4rch) on 2026-11-24T00:53:04Z. --- I compared #1084 with #1077 at `e7ab28b` to find controls to bring over. Every boundary, refusal and mutation in #1084 already has a counterpart in #1077: | #1084 control | In #1077 | |---|---| | i16: 32752 (`0x77ff`) and -32768 (`0xf800`) accepted; 32768 (`0x7800`) and -32800 (`0xf801`) refused | same values, same outcome | | u16: -0.5 (`0xb800`) gives 0, 65504 (`0x7bff`) accepted, -1 (`0xbc00`) refused | same values, same outcome | | ±1.5, both signed zeros, subnormals `0x0001` and `0x8001` | in the i16 and u16 draw tables | | infinity, NaN and unproven SGPR/VGPR sources refused | refused, with exact messages | | missing or invalid binary16 entry state | refused | | mutations: round to nearest, sign error, source read from bits 31:16 | the same three mutations | | low-half SDWA reader accepted, other readers refused | same reader checks | Nothing needs to move. One behavioural difference: #1084 accepts both forms under round toward zero, treating the truncation as defined by the instruction, while #1077 refuses them like the other binary16 forms. I would keep #1077's refusal for this slice, because nothing here measures whether the MODE rounding field affects these conversions. I'm closing #1084 in favour of #1077 and will run an independent LLVM 15 and WARP review of #1077. _AI-assisted._
tedin7 commented 2026-11-24 06:49:59 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T01:04:41Z.


Claiming v_fmac_f16_e32 and v_ldexp_f16_e32 in tools/pixel_aot.py (their disassembly is already in main). The v_cvt_i16/u16_f16 slice is #1077. Environment: Linux with LLVM 19 locally; I rely on the Ubuntu LLVM 15 job and the Windows WARP jobs for the rest. AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118730464 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7118730464). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T01:04:41Z. --- Claiming v_fmac_f16_e32 and v_ldexp_f16_e32 in tools/pixel_aot.py (their disassembly is already in main). The v_cvt_i16/u16_f16 slice is #1077. Environment: Linux with LLVM 19 locally; I rely on the Ubuntu LLVM 15 job and the Windows WARP jobs for the rest. AI-assisted.
R0Y00 commented 2026-11-24 06:50:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T03:17:36Z.


Please go ahead with the two literal-K forms. Keep the low-half definedness rules and the previously tested FMA profile. An LLVM 15 assemble/disassemble check should distinguish which operand receives K. For execution, use different values for both source operands and K, a rounding case that distinguishes a fused result from two operations, and a control that puts the literal in the wrong slot. Keep whole-word and high-half consumers refused where the upper half is unknown.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7120952865 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/839#issuecomment-7120952865). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T03:17:36Z. --- Please go ahead with the two literal-K forms. Keep the low-half definedness rules and the previously tested FMA profile. An LLVM 15 assemble/disassemble check should distinguish which operand receives K. For execution, use different values for both source operands and K, a rounding case that distinguishes a fused result from two operations, and a control that puts the literal in the wrong slot. Keep whole-word and high-half consumers refused where the upper half is unknown.
Sign in to join this conversation.
No labels
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.

Reference
R0Y00/Xbox2Windows#833
No description provided.