tooling: print neg on a VOPC SDWA inline constant as neg(c) #1022
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1029"
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-23T22:09:43Z.
Refs #938
Summary
For a float VOPC SDWA source with neg and without abs on an inline constant (scalar codes 128-208 and 240-248), the decoder printed
-c, or--cfor a negative constant. For an integer constant this text names a different operand.f924027c81009606sets the sign bit of the inline constant 1 (0x80000001), but it printedv_cmp_lt_f32_sdwa vcc_lo, -1, v18 .... That is the same text as the inline constant -1 (f924027cc1008606, 0xffffffff), andpixel_aot.loweraccepted it as -1.This change prints these operands as
neg(c), as LLVM 15 does:neg(0),neg(1),neg(64),neg(-1),neg(-16),neg(0.5),neg(-0.5),neg(1.0),neg(0.15915494)and so on.pixel_aot.lowerrefuses aneg(...)operand (Unsupported arithmetic operand neg(1)), so it no longer lowers the encoding as a different constant.I checked every affected spelling against the #938 sweep data rather than guessing. LLVM prints
neg(c)in exactly the 90 codes x {f32, f16} groups where neg is set without abs on an inline constant. These forms already matched LLVM and do not change:|c|-|c|,-|-1|-1,-0.5-s1,-src_shared_base,-src_vcczThe LLVM-specific float-constant spelling on i16/u16 compares is left unchanged, as agreed on #938.
Files:
tools/disasm_rdna2.py(+14/-2),tests/rdna2_tools_check.py(+90).Tests
New tests are in
tests/rdna2_tools_check.py, which is already registered in CMake and both CI jobs:test_vopc_sdwa_neg_on_inline_constantdecodes 23 records, each followed byv_mov_b32_e32 v3, v4(0403067e). The bytes come from llvm-mc 15.0.7 (-triple=amdgcn--amdpal -mcpu=gfx1013 -mattr=+wavefrontsize32) for the expected text. They cover integer constants 0, 1, 7, 64, -1 and -16 and float constants 0.5, -0.5, 1.0, 2.0, -4.0 and 0.15915494, as src0 and src1, on f32, f16, class and VOPCX compares, plus 7 unchanged spellings. The test checks(offset, length, opcode, text)for each record and for thev_movat offset 8. It also checks two refused records: neg on the integer compare's src0 (f904887d81869606) and on the class compare's src1 (f902117d01860696). Each must bevopc_sdwaat offset 0 with length 8, withv_mov_b32_e32 v3, v4at offset 8.The same test checks that
f924027c81009606andf924027cc1008606now decode to different texts,neg(1)and-1. In the program used by the #938 translator check,pixel_aot.loweraccepts the-1compare (asfloat(4294967295u) < alu20) and refuses the decoder text forneg(1)andneg(0.5)withUnsupported arithmetic operand neg(.test_vopc_sdwa_neg_on_inline_constant_matches_llvmruns only whenLLVM_LIBis set. LLVM 15 must print the same text and next offset for all 23 records, and must refuse both refused records at byte 0.Environment: Windows 11, Python 3.13.1, LLVM 15.0.7 (
LLVM-C.dll,llvm-mc,llvm-objcopy), commitc4b5befon upstream/main64ecc87(measured at50919econcd87907;tools/disasm_rdna2.pyand its tests are unchanged between the two bases, andrdna2_tools_check,shader_census_check,form_coverage_checkanddocs_links_checkwere rerun after the rebase).Lowerer before and after
These are the decoder texts for each encoding and the
pixel_aot.lowerverdicts in the #938 translator program:f924027c81009606(neg(1))-1neg(1)f924027cc1009606(neg(-1))--1neg(-1)f924027cf0009606(neg(0.5))-0.5neg(0.5)f924027cc1008606(inline -1)-1-1Sweep before and after
I ran the independent #938 sweep script (
sweep_980.py: 869,888 VOPC SDWA records, all compared against LLVM 15.0.7) on this commit. Each record is compared with the original #938 run:All 12,131 records moved from
text_mismatchtoboth_decode_match. All 875 remaining text mismatches are i16/u16 compares with noneg(on either side. No record entered a new delta category. Thirteen records that LLVM refuses changed decoder text, for examples230, -5becames230, neg(5). They stay inllvm_refuses_disasm_decodesbecause of their 209-234 scalar code, which the companion branch refuses. Truncated-tail checks: 0 unexpected. Scanner mismatches: 0. Translator verdicts on the canonical records: unchanged (96 accepted and supported, 716 refused and unsupported). The sweep's in-memory negative controls still report their injected defects with 0 deltas outside the expected scope.Negative control
I reverted
tools/disasm_rdna2.pyto upstream/main and kept the new tests.test_vopc_sdwa_neg_on_inline_constantthen fails:With the change restored, both tests pass.
Limits
neg(<float constant>), such asneg(0.5), were lowered correctly before as-0.5f. The lowerer now refuses them, which is a deliberate loss of coverage: one rule refuses every neg-on-inline-constant encoding. The scanner's per-line check (is_instruction_supported) still callsneg(c)lines supported. As before, the lowerer is the authority.v_add_f32_e64 v0, neg(1), v1(000003d581020220) decodes asv_add_f32_e64 v0, -1, v1. That is out of scope here and was not checked against the lowerer.docs/text describes this spelling. The branch merges cleanly with the companion 209-234 branch (git merge-tree).AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T22:22:45Z.
In
750457fI kept the LLVM-compatible spelling and preserved the existing whole-dword f32 comparison for decimal negation. The decoder-to-lowerer controls require identical HLSL forneg(0.5)/-0.5andneg(-0.5)/--0.5. The integer-bit caseneg(1)still refuses and the scanner now agrees, while plain-1keeps its old meaning. Local Python decoder suite: 92 cases, six LLVM-dependent skips; static pixel suite passed. Fresh CI will exercise LLVM 15.