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

Open
opened 2026-11-24 14:52:24 +00:00 by JB2WIN · 3 comments
JB2WIN commented 2026-11-24 14:52:24 +00:00 (Migrated from github.com)
Contributor

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


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).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6584564786 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1606). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-24T14:52:24Z. --- `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).
R0Y00 commented 2026-11-24 16:03:32 +00:00 (Migrated from github.com)
Author
Contributor

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


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7135685027 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1606#issuecomment-7135685027). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T15:14:17Z. --- 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.
triggered02 commented 2026-11-28 17:14:35 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-28T17:14:35Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7242864411 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1606#issuecomment-7242864411). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-28T17:14:35Z. --- 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 commented 2026-11-28 17:25:03 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-28T17:25:03Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7242999695 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1606#issuecomment-7242999695). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-28T17:25:03Z. --- 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.
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#1599
No description provided.