fix(printer): split-window ureg operand decode overwrote instead of merging - #2
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The 8-bit sentinel is lost for the 3-bit low slice, causing URZ to render as UR255.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR fixes split uniform-register decoding so disjoint slices can be recombined during SASS printing.
Changes:
- Replaces slice assignment with accumulator merging.
- Preserves the UR sentinel distinction for future table geometry.
File summaries
| File | Description |
|---|---|
src/printer.rs |
Updates uniform-register slice decoding. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let prev = ureg.unwrap_or(0); | ||
| // 8-bit-window sentinel (URZ=255 vs real UR63) — inherited from | ||
| // the low slice when present, else implied by this 5-bit slice. | ||
| let wide = prev & 0x100; |
There was a problem hiding this comment.
Good catch — fixed in 016e377. You are right that the low slice does not set the sentinel (its width is 3), and that marking the 5-bit high slice itself is sufficient: 31 << 3 = 248 never reaches 255, so a lone ureg_shr3 still renders as before.
I had independently hit this in an end-to-end check (OMMA encoded as URZ came back as UR255) and first fixed it with a separate bit-coverage accumulator; your single-flag version is simpler and does the same thing, so I took the simpler one. Verified after the change: URZ/UR0/UR6/UR8 all round-trip exactly, and the full suite is green at 1406 passed.
…erging
`format_ureg_raw` assigns each uniform-register slice:
"ureg_shr3" => ureg = Some(f.value << 3),
so when one operand scalar is decomposed across disjoint fields the later
slice clobbers the earlier one. A split-window operand therefore decoded
wrong: on SM120 the OMMA block-scale operand (`URi`, PTX `byte-id-a`) is an
8-bit uniform-register index carried as ureg[0:3)@60 + ureg_shr3[3:8)@73,
and the high slice overwrote the low one — an operand encoded as UR6
rendered back as UR0.
OR the slice into the accumulator so the pieces recombine.
The high slice also has to set the 0x100 "wide window" sentinel itself: it
carries bits [3:8) of an 8-bit operand, whereas the low `ureg` slice does
not (its own width is 3). Without the sentinel, URZ — low=7, high=31, raw
255 — rendered as "UR255", and the architectural UR63 stopped being
distinguishable from the sink. A lone `ureg_shr3` slice is unaffected: 5
bits shifted left by 3 top out at 248, never 255.
No table in this revision uses `ureg_shr3` yet, so this is a no-op for the
shipped tables; it is the code-side prerequisite for the sm120 URi
field-geometry correction (companion data change, blackwell-isa).
Verified: full suite green (1406 passed). An OMMA word encoded as UR6/URZ
round-trips exactly with the companion table fix applied.
c16bf26 to
016e377
Compare
format_ureg_rawassigns each uniform-register slice:When one operand scalar is decomposed across disjoint fields, the later slice
therefore clobbers the earlier one instead of merging with it. A
split-window operand decodes wrong as a result.
The concrete case: on SM120 the OMMA block-scale operand (
URi, PTXbyte-id-a) is an 8-bit uniform-register index carried asureg[0:3)@60(low bits) +ureg_shr3[3:8)@73(high bits). With theassignment above the high slice overwrites the low one, so an operand
encoded as
UR6renders back asUR0— the decoded text loses the register.Fix
OR the slice into the accumulator so the pieces recombine:
The
0x100sentinel — which distinguishes the 8-bit-windowURZ(255) fromthe real architectural
UR63— is preserved across the merge, so a loneureg_shr3slice still behaves exactly as before.Compatibility
No table in this revision uses
ureg_shr3, so this change is a strictno-op for every shipped table (SM120 / SM103a / SM100a / SM121A). It is the
code-side prerequisite for the sm120
URifield-geometry correction, whichis PR'd separately against
blackwell-isa.
Verification
cargo test --release: 1406 passed, 0 failed (unchanged before/after,as expected for a no-op against the current tables).
tools/sync_table.py --checkand--validate-only: green (no table touch).OMMA ... UR6word encodes and decodes back toUR6, and every valuefrom
URZ/UR0throughUR32round-trips exactly.Note
cargo clippy -- -D warnings -A clippy::if_same_then_elsefails atmain.rs:5481(unneeded late initialization). That is pre-existing onmainand unrelated to this change — flagging it in case the CI gateneeds attention independently.