Repository navigation
startup: translate VOP3 NEG on an inline-integer or literal float source (follow-up to #2529) - #2563
Merged
Merged
Conversation
The refusal added for NEG on an inline-integer or literal VOP3 source (Part of R0Y00#1723) covered every slot. For a float-typed source slot of the f32 ALU table (VEC_F) and of v_cmp(x)_*_f32 (src0 only for the class compares), translate NEG with the model LLVM's assembler uses when it folds neg into an immediate: bit 31 of the 32-bit source word flipped (inline 1 -> 0x80000001, literal 0x5 -> 0x80000005, inline 0 -> 0x80000000). The word is taken from the encoding, not from the printed text, and emitted as an exact bit pattern. RDNA hardware behaviour for these sources is not measured; the WARP and NVIDIA readback only checks the HLSL against this model. Integer-typed slots, the class mask slot, NEG with ABS on the same source, and everything refused for another reason stay refused. Tests: startup_gfx2hlsl_neg_check.py checks the emitted words for v_fma_f32, v_mul_f32 and v_med3_f32 with NEG on inline 0, 1 and 64 and a literal, and in dispatch mode reads them back on WARP and hardware against a CPU reference (the two subnormal v_mul results may flush to signed zero). startup_gfx2hlsl_refusals_check.py now expects float slots to translate and integer slots, the class mask slot and NEG with ABS to refuse. AI-assisted. # Conflicts: # CMakeLists.txt # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want to. # An empty message aborts the commit. # # interactive rebase in progress; onto 9bef64e # Last command done (1 command done): # pick 19a8c3aa # startup: translate VOP3 NEG on an inline-integer or literal float source # No commands remaining. # You are currently rebasing branch 'vop3-neg-inline' on '9bef64ee'. # # Changes to be committed: # modified: .github/workflows/windows.yml # modified: AGENTS.md # modified: CMakeLists.txt # modified: docs/experiments.md # new file: tests/startup_gfx2hlsl_neg_check.py # modified: tests/startup_gfx2hlsl_refusals_check.py # modified: tools/startup/gfx2hlsl.py #
Resolving the rebase onto main dropped the endforeach() that closes the startup_gfx2hlsl_fma_mix_dispatch loop, so the CMake configure failed. The neg tests now follow the closed loop. AI-assisted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #2529 (claim). Part of #1723.
#2529 refuses NEG on an inline-integer (0..64) or literal source of any VOP3 instruction, because the printed text loses the distinction. This translates it for float-typed source slots instead:
VEC_F:v_fma_f32,v_mul_f32,v_med3_f32,v_add_f32, ...) and ofv_cmp(x)_*_f32. For the class compares, only src0; the mask slot is excluded.neginto an immediate (AMDGPUAsmParser::applyInputFPModifiers); the RDNA 2 ISA lists VOP3 NEG as a float input modifier. Inline 1 gives0x80000001, literal0x5gives0x80000005, inline 0 gives0x80000000. The word is read from the encoding, as startup: refuse NEG on an inline-integer or literal VOP3 source in gfx2hlsl #2529's check does, not from the printed text, and emitted as an exact bit pattern throughF(). RDNA hardware behaviour of NEG on these immediate sources is not measured; the WARP and NVIDIA readback only checks the HLSL against this model.v_cndmask_b32_e64keeps its own handling.Tests (Windows 11, Python 3.14, DXC from the Windows SDK 10.0.26100), on main
9bef64eplus this commit:python -B tests/startup_gfx2hlsl_neg_check.py(new): ok. The emitted word forv_fma_f32,v_mul_f32andv_med3_f32with NEG on inline 0, inline 1, inline 64 and a literal.... dispatch <dxc> <offscreen_check> warpandhardware: ok, on WARP (Microsoft Basic Render Driver) and an NVIDIA GeForce RTX 5080. Each form is compared with a CPU reference built from the encoded words. The twov_mul_f32results that are subnormal may flush to signed zero; the others are compared bit-exactly, including-0.0for inline 0.tests/startup_gfx2hlsl_refusals_check.py: ok. Float slots now translate; integer slots, the class mask slot and NEG with ABS still refuse.startup_gfx2hlsl_bit_alu_check,startup_gfx2hlsl_mad_check,startup_gfx2hlsl_operand_count_check,startup_gfx2hlsl_handler_arity_check,startup_translator_check,startup_gfx2hlsl_f32_nan_check,startup_gfx2hlsl_f32_lg_check,startup_gfx2hlsl_cvt_alu_check,startup_gfx2hlsl_compute_checkandstartup_gfx2hlsl_int_med3_check.Mutation checks, run by hand. Each one fails at least one of the checks above:
Measured on a local capture (counts only, inputs private; requests re-keyed with
shader_cache_rekey.pyfor the current revision): at main9bef64e, 176 pipelines translate (85 graphics, 91 compute), and the #2529 refusal was the first refusal for about 1,400 requests. With this change none stop there, and 179 translate (87 graphics, 92 compute). The rest now stop at refusals that were already there behind it:src_sccins_mov_b32(818), anexeczVCC definition (341),v_readfirstlane_b32proofs (284) and|vN|onv_cndmask_b32_e64(217).AI-assisted.