compute_store_aot: handle unobserved gfx1013 FLAT_SCR_LO writes #1641

Closed
opened 2026-11-24 15:51:57 +00:00 by stan495 · 2 comments
stan495 commented 2026-11-24 15:51:57 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T15:51:57Z.


Refs #721 and #640.

On cb94b8caff25ed8d946e040167265263bc1cb8b5, the source-built gfx1013 INDEXED fixture lowers to HLSL and compiles with DXC. Prepending a whole-register FLAT_SCR_LO write makes compute_store_aot reject the same kernel, even though the kernel never reads the register or accesses scratch memory.

Reproduction

  1. Take INDEXED from tests/compute_store_check.py. Create a second copy with s_setreg_imm32_b32 hwreg(HW_REG_FLAT_SCR_LO), 0 as its first instruction.
  2. Assemble both versions for gfx1013 with the test module's assemble() helper. Wrap each .text binary with store_container(code, (32, 1, 1)) and save the results as out/control.dxbc and out/write-only.dxbc.
  3. Run from the repository root with LLVM_LIB set to your LLVM shared library. The reproduction used AMD LLVM 22.0.0git for assembly and LLVM 17.0.6 for decoding.
for case in control write-only; do
  python3 -B tools/compute_store_aot.py "out/$case.dxbc" \
    --llvm "$LLVM_LIB" --table-reg 7 --descriptor-offset 0x30 \
    --group-reg 11 --stride 16 --output "out/$case.hlsl"
done

The control emits HLSL and compiles with dxc -Gis -T cs_6_0 -E main. The write-only variant exits with code 1 before emitting HLSL.

ValueError: Unsupported compute instruction: s_setreg_imm32_b32 hwreg(HW_REG_FLAT_SCR_LO), 0

Fixed-profile rescan

At the same commit, 13 of 2,689 local compute records generated HLSL across the configured profiles. Among the rejected records, this exact write was the first diagnostic on the first fixed profile for 389 records. A rescan after the change would measure how many reach HLSL generation.

Proposed acceptance criteria

  • Lower the write-only fixture when the scratch-base value has no observable consumer. Compare the UAV output and guard words against the original fixture in a readback test.
  • Keep rejecting a variant that reads FLAT_SCR_LO with s_getreg_b32 and uses the value in the UAV store. Keep rejecting memory forms that depend on the scratch base until their addressing semantics are modeled.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6585806959 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1648). Originally posted by [stan495](https://github.com/stan495) on 2026-11-24T15:51:57Z. --- Refs #721 and #640. On `cb94b8caff25ed8d946e040167265263bc1cb8b5`, the source-built gfx1013 `INDEXED` fixture lowers to HLSL and compiles with DXC. Prepending a whole-register `FLAT_SCR_LO` write makes `compute_store_aot` reject the same kernel, even though the kernel never reads the register or accesses scratch memory. ## Reproduction 1. Take `INDEXED` from `tests/compute_store_check.py`. Create a second copy with `s_setreg_imm32_b32 hwreg(HW_REG_FLAT_SCR_LO), 0` as its first instruction. 2. Assemble both versions for gfx1013 with the test module's `assemble()` helper. Wrap each `.text` binary with `store_container(code, (32, 1, 1))` and save the results as `out/control.dxbc` and `out/write-only.dxbc`. 3. Run from the repository root with `LLVM_LIB` set to your LLVM shared library. The reproduction used AMD LLVM 22.0.0git for assembly and LLVM 17.0.6 for decoding. ```bash for case in control write-only; do python3 -B tools/compute_store_aot.py "out/$case.dxbc" \ --llvm "$LLVM_LIB" --table-reg 7 --descriptor-offset 0x30 \ --group-reg 11 --stride 16 --output "out/$case.hlsl" done ``` The control emits HLSL and compiles with `dxc -Gis -T cs_6_0 -E main`. The write-only variant exits with code 1 before emitting HLSL. ```text ValueError: Unsupported compute instruction: s_setreg_imm32_b32 hwreg(HW_REG_FLAT_SCR_LO), 0 ``` ## Fixed-profile rescan At the same commit, 13 of 2,689 local compute records generated HLSL across the configured profiles. Among the rejected records, this exact write was the first diagnostic on the first fixed profile for 389 records. A rescan after the change would measure how many reach HLSL generation. ## Proposed acceptance criteria - Lower the write-only fixture when the scratch-base value has no observable consumer. Compare the UAV output and guard words against the original fixture in a readback test. - Keep rejecting a variant that reads `FLAT_SCR_LO` with `s_getreg_b32` and uses the value in the UAV store. Keep rejecting memory forms that depend on the scratch base until their addressing semantics are modeled.
R0Y00 commented 2026-11-24 17:02:06 +00:00 (Migrated from github.com)
Author
Contributor

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


The source-built comparison is a good starting point. A focused change can handle the exact whole-register immediate write if the accepted program cannot observe scratch state. Please keep direct reads, scratch-dependent memory operations and unmodeled forms refused, and compare the untouched UAV guards as well as the output. If part of the existing lowering can observe the register implicitly, keep the write rejected on that path. Report any offline acceptance-count change separately from GPU readback.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7137110097 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1648#issuecomment-7137110097). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T16:05:46Z. --- The source-built comparison is a good starting point. A focused change can handle the exact whole-register immediate write if the accepted program cannot observe scratch state. Please keep direct reads, scratch-dependent memory operations and unmodeled forms refused, and compare the untouched UAV guards as well as the output. If part of the existing lowering can observe the register implicitly, keep the write rejected on that path. Report any offline acceptance-count change separately from GPU readback.
triggered02 commented 2026-11-24 17:02:06 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T16:09:57Z.


Taking this, per the scope you set: handle the exact whole-register immediate write when the accepted program cannot observe scratch state, keep direct reads and scratch-dependent memory refused, and compare the untouched UAV guards as well as the output.

Where I will start. compute_store_aot_warp passes on this machine (8.66 s, WARP, dxc from the Windows SDK), so the readback comparison is runnable offline here. I will add the write-only kernel alongside the existing INDEXED fixture, confirm the guard words and the UAV words match the untouched run, and keep two refusals pinned: s_getreg_b32 of FLAT_SCR_LO whose value reaches a store, and a memory form whose addressing depends on the scratch base.

What I will not claim. The offline acceptance-count rescan (389 of 2,689 records hitting this diagnostic) depends on the local record set, which I do not have; if I cannot reproduce that count I will report it as not measured rather than estimating it from the unit fixture.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7137223270 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1648#issuecomment-7137223270). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T16:09:57Z. --- Taking this, per the scope you set: handle the exact whole-register immediate write when the accepted program cannot observe scratch state, keep direct reads and scratch-dependent memory refused, and compare the untouched UAV guards as well as the output. **Where I will start.** `compute_store_aot_warp` passes on this machine (8.66 s, WARP, dxc from the Windows SDK), so the readback comparison is runnable offline here. I will add the write-only kernel alongside the existing `INDEXED` fixture, confirm the guard words and the UAV words match the untouched run, and keep two refusals pinned: `s_getreg_b32` of `FLAT_SCR_LO` whose value reaches a store, and a memory form whose addressing depends on the scratch base. **What I will not claim.** The offline acceptance-count rescan (389 of 2,689 records hitting this diagnostic) depends on the local record set, which I do not have; if I cannot reproduce that count I will report it as not measured rather than estimating it from the unit fixture.
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#1641
No description provided.