Lower v_xor3_b32 in the startup gfx2hlsl translator #2090
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2097"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Ybucaille on 2026-11-25T00:14:06Z.
Item I of #2023.
Summary
v_xor3_b32 vD, a, b, c(RDNA 2 VOP3,D = S0 ^ S1 ^ S2) is added to the three-source integer table intools/startup/gfx2hlsl.py, next tov_or3_b32. It lowers toa ^ b ^ c. Source modifiers,clamp,op_seland a wrong operand count stay refused.Semantics source
LLVM 15 AMDGPU VOP3 definition and the RDNA 2 ISA reference:
D.u = S0.u ^ S1.u ^ S2.u. Same semantics as the compute lowering in #1573.Fixture and controls
tests/startup_gfx2hlsl_bit_alu_check.pygainsv_xor3_b32(existing CMake andwindows.ymlwiring already runs it, including the WARP and hardware draws):x ^ y ^ z.0x13579bdf,0x2468ace0,0xfedcba98and rotations), plus zero, all ones and a repeated source.src0 ^ src1, in the evaluator and in the draw.clamp,-v,|v|,op_sel, two or five operands.Repro
Results (Linux)
v_xor3_b32: 729 inputs matchand the mutation controls.origin/mainthe check stops withUnsupported: v_xor3_b32.{0} ^ {1}, the check fails on729 inputs match the reference./usr/bin/llvm-mc(version 23.1.5).tests/startup_gfx2hlsl_*_check.pyandtests/startup_translator_check.pypass (no-argument mode),tests/docs_links_check.pypasses,git diff --checkis clean.Not run
startup_gfx2hlsl_bit_alu_warp/_hardware) do not run on Linux.binaryas a whole with llvm-mc 23 fails on the existingv_bcnt_u32_b32words (unrelated, the CI uses llvm-mc 15); not run with llvm-mc 15.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T00:34:11Z.
Four mutations on the new table row, all caught — and the arity entry is the one that matters most
v_xor3_b32rowv_or3_b32(a | b | c)(a ^ b), third dropped)3→2(a ^ b) & c)The third is the one I would call load-bearing.
v_xor3_b32is a three-source VOP3 with aNfield on RDNA 2, so a row that declares arity 3 letsv_xor3_b32 v5, v1, v2(two sources) reach the emit path with a missing operand instead of being refused — and the table is the only place that says howmany sources an opcode takes. Your fixture catches it, which means the count is pinned rather than implied by the expression's shape.
One thing I checked because it is what my own open PR is about
#2104sweeps everyop_*handler with operand shapes no decoder produces and fails if a handler answers with anything other thanUnsupported. Againstthis branch,
v_xor3_b32behaves, because the table-driven emit refuses a count mismatch before indexing. So this PR adds a handler that is compliant withthat ratchet rather than one more
PENDINGentry — which is the direction the list should move.A note on the
docs/experiments.mdlineThe one-line change there is the part a later reader will use to decide whether
v_xor3_b32is covered, so it is worth making it say the same thing thefixture does: which forms are accepted, and that modifiers are refused. Right now it follows the surrounding style of naming the opcode only. Not a
blocker — just the cheapest place to record it.
What the fixture does not establish
That the emitted
a ^ b ^ cmatches the ISA's three-source XOR on a device. The parity of a three-input XOR is the same under any association, so the riskhere is lower than for
med3, but the operand order is still taken on trust from the disassembly, not measured.AI-assisted; the check and the four mutations were run locally on Windows 11 build 26300.9974.
Imported from R0Y00/Xbox2Windows. Originally posted by Its3rr0rsWRLD on 2026-11-25T00:39:35Z.
Windows run of the requested draws for #2097, tested at head
09238b61aaf61d5203b3aa2e638ba782197bf7cc.Environment
devpreset, MSVC; built onlyoffscreen_checkand the tests' dependenciesCommand
Results: 6/6 passed
startup_gfx2hlsl_bit_alu_controlsstartup_gfx2hlsl_bit_alu_warpstartup_gfx2hlsl_bit_alu_hardwarestartup_vertex_fetch_formats_controlsstartup_vertex_fetch_formats_warpstartup_vertex_fetch_formats_hardwareRun by Claude (AI-assisted).