Skip to content

shader: lower v_subrev_f32_dpp and more v_writelane_b32 shapes - #3485

Open
Leyukaka wants to merge 1 commit into
R0Y00:mainfrom
Leyukaka:shader-gfx2hlsl-late-gaps
Open

Leyukaka wants to merge 1 commit into
R0Y00:mainfrom
Leyukaka:shader-gfx2hlsl-late-gaps

Conversation

@Leyukaka

Copy link
Copy Markdown
Collaborator

Refs #3478 (items 1 and 2).

What changes

tools/startup/gfx2hlsl.py:

  • v_subrev_f32_dpp: no new lowering. The existing table entry and the DPP pair/broadcast path already give F(v2) - F(v256) (SRC1 minus the permuted SRC0). What refused these shaders was a s_mov_b64 exec, exec / s_mov_b32 exec_lo, exec_lo between the s_wqm and the read. A move of EXEC to itself without modifiers is no longer counted as an EXEC writer by quad_flow_refusals, and in a pixel stage _lower returns before touching the EXEC/WQM state (the instruction writes neither EXEC nor SCC). The other users of writes_exec are unchanged.
  • v_writelane_b32, lanes k and k+32 of one VGPR: accepted in straight-line code when every v_readlane_b32 of the slot follows a last write to the same lane, and at least one such reload exists. Wave32 (slot k & 31) and wave64 (lane k) then read the same write. A read with no prior write, or after a write to the other lane, is still refused.
  • Spill VGPR reused as a vector: accepted in a straight-line pixel stage when the first ordinary use is v_mov_b32 vN, <SGPR or immediate> without modifiers, no instruction in the program writes EXEC, and no lane read or write follows.
  • Descriptor word spilled in a pixel stage: carried as a symbol, as the compute path already does, when the word is a table descriptor symbol naming one value, the code is straight-line and still in the entry block, and formatted_descriptor_from_block proves its local table load. A copied word (s_mov_b32) is refused.

The existing refusal messages and conditions remain for every shape outside these proofs.

Tests

Two new late-gaps <llvm-mc> modes (startup_gfx2hlsl_dpp_quad_broadcast_check.py, startup_gfx2hlsl_sgpr_spill_check.py), registered in tests/cmake/startup_gfx2hlsl_late_gaps.cmake when llvm-mc is found. They assemble the accept and refuse controls for each shape above.

These two modes did not run on our host: llvm-mc is not installed there, so CTest did not register them. The Linux CI job has LLVM 15 and should run them. Until it does, the new accept/refuse controls are unexecuted, and no mutation was run against them.

Passed on our host (pure-Python modes, 0 FAIL): dpp_quad_broadcast, sgpr_spill, dpp_pair, dpp_quad_flow, dpp_quad_swap, spill_branches, compute_spill, compute_mask_spill, mesh57_lane_spill, mesh57_skeleton, mesh57_depth_only, mesh57_loop, mesh57_loop_refusal, gfx2hlsl_refusals, gfx2hlsl_op_refusals, triage_run, refusal_census. The 11 registered ctest entries for these passed.

Not covered

@lukaslw-lab lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed 18434d7c by reading the diff; not built or run.

Verdict: comment. I found no defect in the four proofs, but none of the new accept/refuse controls has run yet. No MUST.

  • SHOULD (before approval): the late-gaps modes ran nowhere at this head. In run 46289500579, the gfx1013 job runs sgpr_spill_check.py only as binary and does not run dpp_quad_broadcast_check.py. The Linux job runs sgpr_spill_check.py with no arguments, and the Windows job registers no *_late_gaps test (no llvm-mc found). So the three widened shapes have no executed test and no mutation. One local run with LLVM 15 llvm-mc, pasted here, would settle it.
  • Self-move of EXEC: writes_exec checks destinations, so only the exact s_mov_b64 exec, exec / s_mov_b32 exec_lo, exec_lo without modifiers leaves the writer list (gfx2hlsl.py:4989). The early return in _lower is pixel-only and comes after the fetch-call check.
  • Lane alias proof: spill_operands refuses register lanes (:9556), so no write to an unknown slot can slip in. last_write[lane & 31] == lane at each read means wave32 and wave64 read the same write. Pairs still refuse with branches (quad_flow_straight) or with no observed reload.
  • Vector reuse: refused unless the first ordinary use is v_mov_b32 v<n>, <non-VGPR> with no modifiers, no instruction in the program writes EXEC, and no lane op follows. Vertex, compute and mesh keep the old refusal (self.kind != 'ps').
  • Pixel descriptor spill: limited to the entry block, a table symbol that names one value, and the unchanged formatted_descriptor_from_block. proven comes from spill_word_proven as in compute. #3486 does not change the block proof, so the two PRs do not interact here.

Tests: CI ran only sgpr_spill_check.py in its old modes (no arguments, binary), both ok. Neither reaches the new lines, since every new control lives in late-gaps.

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