pixel_aot: v_cvt_f32_f64 on proven pairs, and which MODE field rounds it? (scope question) #1606

Open
opened 2026-11-26 23:20:29 +00:00 by github-bot · 3 comments
Owner

@⁠JB2WIN on GitHub · 2026-11-24 14:52 UTC · original

tools/pixel_aot.py now tracks the provenance of binary64 pairs (#1575), covering conversions into binary64 (#1363, #1446) and out to i32/u32 (#1492). That leaves v_cvt_f32_f64 as the last conversion. Unlike the others, it can round, so I'd like to settle two things before I build it.

1. Which rounding and denormal field applies? The result is binary32 but the source is binary64. MODE[1:0]/MODE[5:4] are the binary32 rounding and denormal fields, and MODE[3:2]/MODE[7:6] are the binary16/binary64 fields; the comment above HALF_ROUNDING describes these. I have not found a public statement of which pair the hardware uses for this conversion. The LLVM 15 TableGen does not say either, so I don't want to guess.

2. Proposed first slice, independent of the mode. Accept only cases whose result needs no rounding and is not subnormal. Then neither field matters:

  • Static v_cvt_f64_f32 pairs (known bits): always exact back to the original binary32, because widening is exact and narrowing it again is exact. I would compute the result at translation time and check it with struct round-tripping.
  • v_cvt_f64_i32/v_cvt_f64_u32 pairs: refused in this slice. A runtime integer above 2^24 rounds, and the translator cannot prove the source magnitude.
  • Refused: everything else, which includes unknown pairs, special values other than the exact ±0 and ±inf of a static pair, _e64, clamp, omod and modifiers.

If you know which MODE field governs the conversion, or have a native reference for it, the integer pairs could follow under a declared rounding profile. This first slice would be small, but it would close the provenance round trip for statically known values. If it isn't worth a PR on its own, tell me and I'll leave it until the rounding question is settled.

AI-assisted (Claude Code).

**@⁠JB2WIN** on GitHub · 2026-11-24 14:52 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1606) `tools/pixel_aot.py` now tracks the provenance of binary64 pairs (#1575), covering conversions into binary64 (#1363, #1446) and out to i32/u32 (#1492). That leaves `v_cvt_f32_f64` as the last conversion. Unlike the others, it can round, so I'd like to settle two things before I build it. **1. Which rounding and denormal field applies?** The result is binary32 but the source is binary64. `MODE[1:0]`/`MODE[5:4]` are the binary32 rounding and denormal fields, and `MODE[3:2]`/`MODE[7:6]` are the binary16/binary64 fields; the comment above `HALF_ROUNDING` describes these. I have not found a public statement of which pair the hardware uses for this conversion. The LLVM 15 TableGen does not say either, so I don't want to guess. **2. Proposed first slice, independent of the mode.** Accept only cases whose result needs no rounding and is not subnormal. Then neither field matters: - **Static `v_cvt_f64_f32` pairs** (known bits): always exact back to the original binary32, because widening is exact and narrowing it again is exact. I would compute the result at translation time and check it with `struct` round-tripping. - **`v_cvt_f64_i32`/`v_cvt_f64_u32` pairs:** refused in this slice. A runtime integer above 2^24 rounds, and the translator cannot prove the source magnitude. - **Refused:** everything else, which includes unknown pairs, special values other than the exact ±0 and ±inf of a static pair, `_e64`, `clamp`, `omod` and modifiers. If you know which MODE field governs the conversion, or have a native reference for it, the integer pairs could follow under a declared rounding profile. This first slice would be small, but it would close the provenance round trip for statically known values. If it isn't worth a PR on its own, tell me and I'll leave it until the rounding question is settled. AI-assisted (Claude Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:20:29 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 15:14 UTC · original

Go ahead with the mode-independent slice. Reuse the proven pair tracking from #1575 and accept only a statically known normal binary32 value or signed zero that returns bit-for-bit after widening and narrowing. Keep both infinities, NaNs, subnormals, unknown pairs, integer-origin pairs and modifiers outside this first slice. Include both signed zeros, representative normal endpoints, a word clobber or unequal join, and a value requiring rounding as refusals. Use LLVM round-trip and raw integer readback. Leave selection of the MODE field open until independent native evidence distinguishes the two fields.

**@⁠R0Y00** on GitHub · 2026-11-24 15:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1606#issuecomment-7135685027) Go ahead with the mode-independent slice. Reuse the proven pair tracking from #1575 and accept only a statically known normal binary32 value or signed zero that returns bit-for-bit after widening and narrowing. Keep both infinities, NaNs, subnormals, unknown pairs, integer-origin pairs and modifiers outside this first slice. Include both signed zeros, representative normal endpoints, a word clobber or unequal join, and a value requiring rounding as refusals. Use LLVM round-trip and raw integer readback. Leave selection of the MODE field open until independent native evidence distinguishes the two fields.
Author
Owner

@⁠triggered02 on GitHub · 2026-11-28 17:14 UTC · original

Claiming the mode-independent first slice described in your last comment. I will reuse the proven-pair tracking from #1575 in tools/pixel_aot.py and accept only a statically known normal binary32 value or signed zero that round-trips bit-for-bit through a binary64 pair. Infinities, NaNs, subnormals, unknown pairs, integer-origin pairs, _e64, clamp/omod and modifiers stay refused; so do the word-clobber/unequal-join, unequal-precision and rounding-required controls you listed. Evidence will be the pure-Python pixel_aot checks on this Debian x64 host (Python 3, LLVM round-trip and raw integer readback); I cannot supply Windows or hardware evidence here. The MODE field question stays open as you requested. No game files, dumps or personal paths will be shared.

**@⁠triggered02** on GitHub · 2026-11-28 17:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1606#issuecomment-7242864411) Claiming the mode-independent first slice described in your last comment. I will reuse the proven-pair tracking from #1575 in tools/pixel_aot.py and accept only a statically known normal binary32 value or signed zero that round-trips bit-for-bit through a binary64 pair. Infinities, NaNs, subnormals, unknown pairs, integer-origin pairs, _e64, clamp/omod and modifiers stay refused; so do the word-clobber/unequal-join, unequal-precision and rounding-required controls you listed. Evidence will be the pure-Python pixel_aot checks on this Debian x64 host (Python 3, LLVM round-trip and raw integer readback); I cannot supply Windows or hardware evidence here. The MODE field question stays open as you requested. No game files, dumps or personal paths will be shared.
Author
Owner

@⁠triggered02 on GitHub · 2026-11-28 17:25 UTC · original

Withdrawing my claim: after checking current main I found the mode-independent slice already implemented in tools/pixel_aot.py (v_cvt_f32_f64 lowering with the proven static-pair record, cvt_f32_f64_exact_bits round-trip check and the refusal controls). My earlier comment predated that check; no PR from me is coming for this issue.

**@⁠triggered02** on GitHub · 2026-11-28 17:25 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1606#issuecomment-7242999695) Withdrawing my claim: after checking current main I found the mode-independent slice already implemented in tools/pixel_aot.py (v_cvt_f32_f64 lowering with the proven static-pair record, cvt_f32_f64_exact_bits round-trip check and the refusal controls). My earlier comment predated that check; no PR from me is coming for this issue.
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/R0Y00--Xbox2Windows#1606
No description provided.