Skip to content

Recompiler: wave64 VS / PS on 32-lane waves – votes are taken per half (not only lane reads) #336

Backlog

Description

@emirduran707

docs/wave64-on-wave32.md treats a 32-lane wave of a console wave64 VS / PS as a console wave whose lanes 32..63 are not populated, so per-lane code and masks count as exact and only reads of lanes ≥ 32 are hazards (upper_lanes.rs, #133). That misses a second way the result can depend on how the driver cuts the wave: wave-wide votes are taken per half.

  • s_cbranch_vccnz / vccz, execz / execnz, scc* after a compare of a lane mask: on the console the 64 lanes go one way if any lane votes yes. Cut in two, the half with no yes lane takes the other side, which the console wave never ran for those lanes. If that side does more than skip lane-masked work, the half's output differs.
  • A scalar defined behind such a vote is then defined in one half and not the other.
  • Lane counts, ranks, first-lane indices and the lane id (s_bcnt1 of a mask, v_mbcnt, s_ff1) take different values in a half than in the wave.

wave_hazards says nothing about these, so 0 hazards does not mean a wave64 PS is exact on 32-lane waves (NVIDIA, and AMD drivers that pick 32 for a PS). How many programs of the retail pack this reaches is not measured yet; step 3 below measures it.

Plan – classify first, fix later, each PR on its own:

  1. Preparation, no behaviour change: share upper_lanes::successors and add post-dominators / control dependence over a program's instructions, with unit tests.
  2. A classifier, not called by translation: per wave64 VS / PS a tier (exact as is / exact through a known idiom / may differ) and the reasons, from a forward taint pass (partition-dependent values reaching exports, stores, branch conditions, EXEC) plus rules for votes that only skip lane-masked work. Unit tests on hand-written programs.
  3. An ignored census test over XCL_SAMPLE_RPF, like retail_wave64_graphics_lane_census, and the measured counts in docs/wave64-on-wave32.md.
  4. Then the may-differ cases one at a time, each with a GPU test.

AI-assisted: Claude Code (Claude Opus 5.5) wrote this issue.

Activity

  1. emirduran707 commented on Nov 24, 2026

    @emirduran707
    ContributorAuthor

    Progress, as a stack (each PR's own commit on top of the one below):

    1. Recompiler: basic blocks, post-dominators and control dependence (#336) #341 – basic blocks, post-dominators, control dependence (no behaviour change).
    2. Recompiler: classify wave64 VS / PS by whether a 32-lane cut changes them (#336) #517 – the classifier: taint pass, vote rules, sinks, and scalars written behind a vote (Recompiler: scalars written behind a vote and read after it are partition-dependent (#336) #528 folded in). After three reviews (QemmHD, CuteBooty, upipibi), over the pack's 13 210 wave64 VS / PS: 6 057 Exact.
    3. Recompiler: a vote's side may narrow EXEC through a whole-quad copy (#336) #953 – a vote's side may narrow EXEC through a whole-quad copy (the console compiler's discard early-out): 7 015 Exact.

    A probe over the pack shows where the rest is. Among the programs that are not Exact, 2 409 had vote-branch as their only reason; most of those were the discard early-out that #953 handles. Waterfall loops (v_readfirstlane + v_cmp_eq of it) are rare: 1 of the 520 programs whose only reasons are cross-lane / tainted-exec / lane-id. So the next parts will be chosen by such probes rather than by idiom names. After that: the census as an ignored test with the counts in docs/wave64-on-wave32.md, then the may-differ cases one at a time with GPU tests.

    AI use: Claude Code with Claude Opus 5.5 wrote this note.

  2. added 2 commits that reference this issue on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions