shader: lower the 64-bit VOP3 shifts in pixel_aot #957
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/964"
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 MasterDomino on 2026-11-23T19:02:30Z.
Change
Implements #928 as scoped there:
tools/pixel_aot.pylowers the 64-bit VOP3 shiftsv_lshlrev_b64,v_lshrrev_b64andv_ashrrev_i64. These are opcodes 767-769 in the AMD RDNA 2 ISA guide §12.12:D = S1 << S0[5:0],S1 >> S0[5:0]andsignext(S1) >> S0[5:0].int64_operand), so the HLSL needs no 64-bit type.& 63u). Onlyv_ashrrev_i64fills with the sign bit.lo/hitemporaries before the destination pair is written, so the in-place LLVM form keeps the original value.sh < 32u ? … : …). Every 32-bit HLSL shift count issb = amount & 31,32u - sbwhensb != 0, or31u. A 32-bit HLSL shift never receives a count of 32 or more, which HLSL would wrap.violates constant bus restrictions._e64spelling lowers identically to LLVM's suffix-less print._e32,clamp,op_sel, source modifiers, a destination that is not a pair withinv0..v255or that has an outstanding image sample, float amounts, a literal value, untracked sources, and use inside a masked region. Two refusals come from the existingint64_operandand keep its "64-bit comparison" wording.tools/scan_unsupported_shaders.pygets a pattern for the same operand shapes, including the one-scalar rule.tests/rdna2_tools_check.py::test_shift64_scanner_supportpins it.Refs #928
Verification
Upstream
mainat185ffbe, Fedora 45 x86_64, Python 3.15.2, LLVM 15.0.7.All exit 0, and so do the 26 platform-independent checks and
tests/ffx_dispatch_aot_check.pywith LLVM 15.sb,32u - sbor31u.asintappears only forv_ashrrev_i64.lo/hireads precede both destination writes._e64lowers identically.0xffffffc1,0x80000020,0xffffffff) × 3 instructions.check_shift64_drawran with the Linux DXC 1.9.2609 release and only the D3D12 calls replaced by recorders. All 12 shaders compile (9 programs and 3 mutants), and 270 well-formed integer cases are written.Not run here:
pixel_aot_shift64_warp. It needs Windows; this PR's CI run is the first WARP result.0x41(wraps to 1); and an SGPR-pair value next to the inline-1.0xffffffc1and0x80000020.R32G32B32A32_UINT, againstshift64_reference, which is written from the ISA formulas.v_ashrrev_i64shaders that must mismatch: the amount masked to five bits, the sign fill replaced with zeros, and the result words swapped.No
_hardwarerun is reported.Evidence and follow-up
All fixtures are source-built. Two inputs are assumed, not sourced:
The draw pins the translator's model on a desktop adapter; it is not evidence for gfx1013 execution. On one local input (the 12,101 PS records from #932, aggregates only),
v_lshlrev_b64appears in 255 records (2.1%), and the other two shifts don't appear.Checklist
docs/experiments.md, next to the 64-bit comparisons.)AI-assisted.
🤖 Generated with Claude Code
https://claude.ai/code/session_01B48PpcRN2Er51keRf2DsS5
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T19:21:45Z.
I made the carry-side shift count stay in 0..31 even in the unselected arm at a zero subshift. That keeps both generated dword shift expressions in range while preserving the zero carry. The existing static controls, full LLVM 15 binary pass, and shift64 readbacks on WARP and RTX 4060 Laptop all passed with the change. The author fixtures and mismatch controls are unchanged.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-23T19:26:02Z.
Thanks for the fix, you're right. HLSL evaluates both arms of
?:, so with a zero sub-shift the unselected arm computedlo >> 32. That value was always discarded, and HLSL masks the count, which is why the readback and my model agreed. But my description's claim that no 32-bit shift receives a count of 32 or more was wrong, and my static control only matched the(32u - sb)spelling instead of checking the range.sc = (32u - sb) & 31ucloses it properly.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by lantiumBot on 2026-11-23T20:07:16Z.
First
_hardwareresult for this draw, on RDNA 4. Data only.pixel_aot_shift64_hardwarepassed on an AMD Radeon RX 9060 XT, andpixel_aot_shift64_warppassed on in-box WARP, at mergedmain.f8e80e5663097c3ccc6fd35adbe4fba65e0fbf2e, clean tree,devpreset (Debug)One run per backend, 0 capability skips. The test prints no per-case lines on success, so this reports the CTest verdict only: the positive cases matched and the three mutated
v_ashrrev_i64shaders mismatched as the fixture requires.For context, the full
ctest --preset dev --no-tests=error -R '_hardware$'run at this commit gave 137 tests: 133 passed, 1 capability skip (bc7_mode6_multiblock_hardware), 3 failed. The three failures are the rows already recorded for RDNA 4 (dxr_opacity_hardware,gpu_alias_lookup_writes_hardware,pixel_aot_comparisons_hardware, #958).AI-assisted (Claude Code - Fable 5.2); runs executed locally on the adapter above.