Repository navigation
Conversation
…d shows the literal as an exp (SHADER-804) LLVM 21.1.8 cannot decode v_pk_* / v_fma_mix* with a 32-bit literal: it prints an invalid word and reads the instruction's second word and the literal as other instructions, an exp when the literal's top byte is 0xF8..0xFB. 22.1.8 and 23.1.6 decode them. shader_disasm and fspx_unpack --disasm now stop, naming the version, when a packed literal is lost; docs, CI and build_llvm_mc.ps1 move to LLVM 22.
…l packed-literal decode test, testing.md on LLVM 22
kacper-serewis
left a comment
There was a problem hiding this comment.
At 401ac9c, LLVM 22.1.2 passes the new preflight but all five affected FSPX programs still fail via the normal entry point. All 29 cached exports were freshly disassembled for gfx1030. LLVM 22.1.2 translated and validated 21/29; diagnostic LLVM 21.1.8 (preflight bypassed) and the historical cache both gave 22/29. One additional program fails printed-encoding parity on 22.1.2. Please narrow the version claim and verify any proposed floor against the affected programs. This does not establish the minimum working version. AI-assisted CPU review.
|
A no-regression check with llvm-mc 23 (I have the DLL, not llvm-mc 21), on my own 1.0.2.1 copy, Windows,
So under LLVM 23 the change is a no-op for these programs, as it should be. The remaining 3 failures are the ones LLVM 23 already had (03 and 18, the |
kacper-serewis
left a comment
There was a problem hiding this comment.
SHADER-804 follow-up at 401ac9c on the same 29 cached FSPX exports through the normal pipeline. LLVM 22.1.8: 29 listings, 322 invalid words in 11 listings, 21 translated and Vulkan-valid. LLVM 23.1.6: 29 listings, 89 invalid words in eight listings, 26 translated and valid. It retained every 22.1.8 success. This directly checks the requested 22.1.8 release; 23.1.6 is the better of the tested versions, and three programs remain unvalidated. AI-assisted CPU only.
|
Thanks @kacper-serewis, that is a real gap in my claim: I measured the packed-literal decode on hand-built words with 22.1.8 and 23, never on 22.1.2 or on the real programs. I will (1) find the LLVM change that fixed VOP3P-with-literal decoding and the first release that has it, (2) run the probe words through every 22.1.x I can get, and (3) make the floor whatever that shows (a point release, or 23) with the probe checking the exact behaviour rather than the major version. Could you share which instruction the five programs fail on under 22.1.2 (the line before the |
Claimed in the coordination issue as: #4683 (comment)
Why
SHADER-804: with llvm-mc 21.1.8, five FidelityFX FSPX programs (05, 06, 08, 09, 28) fail to translate ("reachable instruction with normalized encoding", one
expin each); with llvm-mc 23 they translate, and rafaelpssz found that 23's listing has noexpat all.The
expis not an EXP encoding problem. Measured on a pod (gfx1010/gfx1030/gfx1013; llvm-mc 21.1.8, 22.1.8, 23.1.6; no game files):exp mrt0 off, ...in 21/22,exp mrt0, off, ...in 23). All three re-encode the reserved bits and the vsrc of disabled channels as 0. Nothing 21 prints asexpis a different opcode family, and the top-6-bit 0xFC.. words are invalid in all three. So (a) and (b) have nothing to handle.v_pk_mul_f16 v0, v1, 0xfbff3c00(bytes00 40 10 cc 01 ff 01 1a 00 3c ff fb) is aninvalid instruction encoding; it skips 4 bytes, reads the second word asv_dot4c_i32_i8and the literal asexp mrt0 off, off, off, off done compr vm. A literal whose top byte is 0xF8..0xFB does that, such as an f16 pair with -65504 (0xFBFF) in the high half. Same for v_pk_add_f16, v_pk_max_f16, v_pk_min_f16, v_pk_add_u16, v_pk_lshlrev_b16, v_pk_mul_lo_u16 ... 22.1.8 and 23.1.6 decode all of them, on gfx1010, gfx1013, gfx1030 and gfx1036.v_pk_*,v_fma_mix_f32,v_fma_mixhi_f16,v_fma_mixlo_f16); 22 matches 23 on all 71. For VOP3 the same count is 563 of 732 differ under 21 (22 matches 23 on all). Random words (150,000, gfx1030) also show 21 rejectingsrc_flat_scratch_base_lo/hioperands, which 22/23 accept.expcomma and in 23 accepting register tuples that run past s105 ([s104,s105,vcc_lo,vcc_hi]); 22 prints the stored 0 in unused VOP3 source fields like 21, 23 prints 0x80 (already handled, Translator: accept LLVM 23's 0x80 in unused VOP3 source fields; check for a .NET SDK #223).The rejected instruction is lost from the listing (the translator re-anchors only what LLVM printed), so no translator rule can recover it: the choice is (c), raise the documented minimum, and make the tool enforce it. Related: #4595 refuses a reachable fall-through into undecodable words; this PR keeps such listings from being produced in the first place. It does not conflict with #4697, #2038, #2323.
What
tools/shader_disasm.py:require_packed_literals(mcpu)disassemblesv_pk_mul_f16 v0, v1, 0xfbff3c00once per process (cached) and stops, naming the llvm-mc's LLVM version and the fix, when llvm-mc reports an invalid instruction or prints anexp. It runs insideprobe()(shader_disasm) and infspx_unpack.py --disasm, after its output-folder checks. An llvm-mc that fails for another reason is left to the existing per-shader reporting. The one extra llvm-mc run adds about 15 ms once.scripts/build_llvm_mc.ps1default-Version21.1.8 to 22.1.8 (tag llvmorg-22.1.8 exists; the script was not run, no Windows here). The conda route in README has no version pin (docs/testing.md already used 23.1.6)..github/workflows/ci.yml(translator-tests): installs llvm-22 from apt.llvm.org/noble (the 22 repo answers 200 for noble and jammy) and checksLLVM version 22..runtime.ymluses llvm-18 only to assemble GPU fixtures, which this does not touch.translator-testsjob (LLVM 22) now also runstests/test_shader_disasm.py::PackedLiteralTest, so the real-llvm-mc decode test runs there instead of being skipped.tests/test_shader_disasm.py(LLVM-21-like fake is refused with "LLVM 21.1.8" and "LLVM 22 or newer", no listing written; a real llvm-mc decodes the packed literal with 0 invalid words, skipped when no AMDGPU llvm-mc),tests/test_fspx_unpack.py(same refusal for--disasm, one fake adjusted so it only warns on shader input),tests/test_make_game_pipeline_preflight.py(message text).Tested with numbers
On a RunPod pod (Ubuntu 22.04, Python 3.13, no GPU needed), fresh copy of the tree each time:
test_llvm_21_is_refused_with_its_version_and_the_fix,test_llvm_21_losing_packed_literals_stops_before_any_listing), 53 passed. With this change: 92 passed, 3 skipped (shader_disasm, fspx_unpack, fspx_unpack_out, mc_command, fspx_shaders_stage); with 23.1.6: 55 passed, 1 skipped.shader_disasm.pyon a one-shader FSSM with the packed literal exits 1 with "'/usr/lib/llvm-21/bin/llvm-mc' is LLVM 21.1.8: it cannot decode a packed-math (VOP3P) instruction ... Use LLVM 22 or newer"; the real-llvm-mc test fails on 21 as intended; with 22.1.8 the same file givesv_pk_mul_f16 v0, v1, 0xfbff3c00, 0 invalid words.test_skip_assets_preflight_reduces_disk_space_requirement:posixpath.isjunction;test_parity_with_llvm_mc_on_shader_fixtures, exp null, TEST-1010: rdna2_decode: exp null is a special operand, as shader_ir parses it #4697), not touched here.Follow-up after review, RunPod pod, LLVM_MC = 22.1.8:
test_make_game_preflight80 passed (the two "LLVM 22+" message checks were red before),test_make_game_pipeline_preflight15,test_shader_disasm28,test_fspx_unpack27,test_ci_registration11,test_docs_links6 passed.pytest tests/test_shader_disasm.py::PackedLiteralTest(whattranslator-testsnow runs): 8 passed, the real decode test not skipped; with llvm-mc 21.1.8 the same command fails on the real decode test.Not covered
expsits right after aninvalid instruction encodingfor av_pk_*orv_fma_mix*word with a 0xFxxxxxxx literal.build_llvm_mc.ps1with 22.1.8 and the CI job on a GitHub runner were not run.Thanks to VeTkN for the report and rafaelpssz for the clue that 23.1.3 lists no
expat all.AI-assisted (Claude Code). No game files.