Recompiler: apply ABS / NEG on v_mov_b32, v_cndmask_b32 and two cvts #802
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!802
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-802"
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?
@upipibi on GitHub · 2026-11-24 05:37 UTC · original
upipibi:fix/vop-abs-neg→main· +92 −6 · 4 files · 2 commits · openThe VOP3 (and SDWA / DPP16) forms of
v_mov_b32,v_cndmask_b32,v_cvt_f32_f16andv_cvt_f64_f32take the ABS / NEG source modifiers, and XCL dropped them on both backends: the four arms used the raw source, while every other float source goes throughfsrc/fh/f64v.v_cndmask_b32_e64 v5, -v1, |v2|, vccwith v1 = 1.0, v2 = -2.0 gave 1.0 / -2.0 where -1.0 / 2.0 is right.References: the RDNA 2 ISA says of
V_CNDMASK_B32andV_MOV_B32that floating-point modifiers are valid and the instruction "is suitable for negating or taking the absolute value of a floating-point value" (VOP2 opcode 1, VOP1 opcode 1, with the examplev_mov_b32 v0, -v1). LLVM foldsfneg/fabsof select operands intoV_CNDMASK_B32_e64(VOPSelectModsPat,SIInstructions.td), and its MC tests encodev_cndmask_b32_e64 v5, -v1, |v2|, vcc(gfx10_asm_vop2.s),v_cvt_f32_f16_e64 v5, -v1andv_cvt_f64_f32_e64 v[5:6], -v1(gfx10_asm_vop1.s). LLVM itself never puts modifiers onv_mov_b32(VOPProfile_MOVhas none); the ISA text is the only source for that one.The modifiers are applied on the sign bit, as
valu64already does for f64 sources (abs clears it, then neg flips it). The move and the select stay untyped, so a NaN keeps its payload and -0 and denormals pass bit-exact. Forv_cvt_f32_f16they act on bit 15 of the f16 input, forv_cvt_f64_f32on the f32 input.What is in it
crates/xcl/src/gpu/recomp/emit.rs: helpersign_mods, used by thev_mov_b32/v_mov_fed_b32,v_cndmask_b32andv_cvt_f32_f16arms ofvaluand thev_cvt_f64_f32arm ofvalu64.crates/xcl/src/gpu/dxil/lower_valu.rs,lower_wide.rs(second commit): the same on the direct translator.Lw::sign_modapplies abs / neg on the sign bit; it is used by thev_mov_b32/v_mov_fed_b32,v_cndmask_b32andv_cvt_f32_f16arms and byv_cvt_f64_f32invalu64.crates/xcl/src/gpu/recomp/tests.rs: GPU testgpu_abs_neg_on_move_select_and_conversions.v_cndmask_b32_e64 -v1, |v2|with VCC alternating per lane, on (1.0, -2.0), a quiet NaN with a payload against a negative signalling NaN, (-0, -0) and denormals;v_mov_b32_e64 -v1and-|v2|on the same inputs;v_cvt_f32_f16_e64 -vand|v|on 1.0, -0, -2.0, 0.5;v_cvt_f64_f32_e64 -vand|v|on 1.0, -0, -3.5, 0.25. All results compared as bits.Tested
fed16e7, as-is: Radeon RX 7800 XT (RDNA3, native wave64, driver 32.0.31035.1003), Windows 11, debug, DXC 1.9.0.5512.gpu_abs_neg_on_move_select_and_conversionspasses withXCL_DIRECT_DXIL=0and=1.gpu_tests: 135 passed, 1 failed with=0; 134 passed, 2 failed with=1. Workspace (--test-threads=4): 1154 passed, 1 failed. The failures aren't this PR's.fuzz_validate_and_gpu_1(seed 722) is the known RDNA3 failure onmain.gpu_image_get_resinfo_1d_arrayon the direct path comes from this head's basecbc296a, which predates #2046's fix for it (5ebaf3eb).maincbc296a(one conflict:mainchangedv_rcp_f64torcp_d; kept that). Atfed16e7: the new test passes withXCL_DIRECT_DXIL=0and1;gpu_tests 135 passed withXCL_DIRECT_DXIL=0, 134 passed and 1 failed with1. The failure isgpu_image_get_resinfo_1d_array, which fails onmaintoo (#2046 fixes it).dxilunits: 151 passed.XCL_DIRECT_DXIL=1at its first assertion (lane 0v_cndmask_b32 -v1, |v2|gave0xC0000000, expected0x40000000).cargo test --workspace --no-fail-fast -- --test-threads=4on 228f8e9: 705 passed, 0 failed, 41 ignoredgpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64)main(d5442d2) without theemit.rschange, at its first assertion: lane 0v_cndmask_b32 -v1, |v2|gave0xC0000000(-2.0), expected0x40000000(2.0). It passes with the change.Regression run
Pair for the current head
fed16e7againstmain426a5a7, run by ThiagoAlexsander on the retail title (comment, thanks): RTX 5080 16 GB,scripts/smoke.ps1 -Seconds 60. Pasted as printed.Earlier pair, on the first version (
228f8e9, HLSL change only), run by eizispark on an AMD Radeon RX 9070 XT (thanks):main:
PR:
Not tested
v_mov_b32: the ISA says so, but no compiler I could check emits it.Modsand now the same path, but the test uses VOP3 only.AI use
🤖 Generated with Claude Code
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@upipibi on GitHub · 2026-11-24 05:38 UTC · original
@eizispark, thanks again for the #761 pair. If you have time for more, these four of ours also only need the
xcl-smokepair (mainplus head, same title and duration); they're recompiler and disassembler changes:228f8e920d1c45bfbeea77a978aa41b7af19587ev_swaprel_b32destination index):4db1a2a4a3d03b3f5eb559670c1f584fbbdd055c// pc:comments):5a60d0dad6be82337d8a41fcafdd3f73c9f8be95ec0aa67f44ffb13fcf73db4e9f9d8548a972d2e2I'll copy the blocks into each Regression run with credit. No pressure if you're busy.
@MesshM on GitHub · 2026-11-24 05:46 UTC · original
Test run of
228f8e920d1c45bfbeea77a978aa41b7af19587eon AMD RDNA4. I merged it onto currentmaine50836blocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 705 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 664 passed, 0 failed, 21 ignoredSKIPPED;gpu_abs_neg_on_move_select_and_conversionspasses.Review: ABS / NEG are applied on the bits (clear / flip the sign bit at the operand's width), which keeps NaN payloads and matches how the hardware applies float modifiers to moves and selects. I found nothing to change.
Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@mastrr9 on GitHub · 2026-11-24 05:57 UTC · original
Independent native Windows NVIDIA RTX 5080 (wave32) + D3D12 debug layer build/test run and code review at head
228f8e920d1c45bfbeea77a978aa41b7af19587e.Code Review
sign_modshelper (absclears the sign bit first, thennegflips it, preserving NaN payloads,-0, and denormals) applied tov_mov_b32/v_mov_fed_b32,v_cndmask_b32,v_cvt_f32_f16(16-bit sign0x8000), andv_cvt_f64_f32. No issues found.Tested
617.42/32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), D3D12 debug layer installed (d3d12SDKLayers.dll),rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC from Windows SDK10.0.26100.0, debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4ok, executed on RTX 5080, not skipped):gpu::recomp::tests::gpu_abs_neg_on_move_select_and_conversionsgpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64)gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)Not tested
AI use: Antigravity (Gemini 4 Neon reviewed the diff; Gemini 4 Hydrogen ran the RTX 5080 workspace tests) drafted this report.
@eizispark on GitHub · 2026-11-24 06:06 UTC · original
Hardware check of
228f8e920d1c45bfbeea77a978aa41b7af19587e(verified clean merge withmainbeaa245): pass.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profilecargo test --workspace -- --test-threads=4:705 passed, 0 failed, 41 ignored(GPU tests skipped on this adapter:none)cargo test -p xcl --lib gpu_abs_neg_on_move_select_and_conversions:1 passed, 0 failedRegression run
main(f4ce27c):PR (
228f8e9):Not tested
AI use
scripts/smoke.ps1harness on this machine and formatted this report.@upipibi on GitHub · 2026-11-24 06:07 UTC · original
Thanks @eizispark: both blocks are now in Regression run, credited.
@SlopTart on GitHub · 2026-11-24 06:41 UTC · original
2|
3|AMD/wave64 + release-build datapoint - the axes your row lists as not tested.
4|
5|Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Wine = Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust 1.100.0 cross
x86_64-pc-windows-gnu, release profile,XCL_NETWORK=0, native wave64. Same rig as my Linux rows in #42 / #718.6|
7|Merged state: head
228f8e9onto mainbeaa245, clean merge.8|
9|Full suite,
cargo test --workspace --release --no-fail-fast -- --test-threads=4: 704 passed, 10 failed, 41 ignored (17 suites). The 10 = this rig's 7 stable Wine-lane failures (my #42 row) + the #718 flaky trio firing that run (~2/5 rate, PR-independent). Nothing new fails. Your test passes bit-for-bit on RDNA3:gpu_abs_neg_on_move_select_and_conversionsok.10|
11|Not tested: retail titles (none here), Windows, RDNA4.
12|Counts only, no game data.
13|AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
@DavidM1911 on GitHub · 2026-11-25 10:58 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@raylitebull on GitHub · 2026-11-25 11:06 UTC · original
Diff review on \ed16e7\ (\lower_valu.rs, \lower_wide.rs, \emit.rs, \ ests.rs) looks clean, and \Build and test\ is green. Two items remaining before merge: update Regression run in the PR body from \228f8e9\ to \ed16e7\ (to pass \PR description), and add an AMD GPU verification run covering \ed16e7\ (with \XCL_DIRECT_DXIL=1\ and \
@upipibi on GitHub · 2026-11-25 11:19 UTC · original
@raylitebull The smoke pair in the body is a run of
228f8e9, so I can't just change the commit tofed16e7: the block has to name the head that was run. I've asked for a fresh pair atfed16e7and an AMD run in #1607 (request), and I'll paste them here when they come.@oni-swr on GitHub · 2026-11-25 12:51 UTC · original
Test report: AMD Radeon RX 7800 XT (RDNA3, native wave64) for head
fed16e7da66f8fbd563146123485168fd759fb96(requested on #1607).Setup: RX 7800 XT, driver 32.0.31035.1003, Windows 11 Pro 10.0.26200, rustc/cargo 1.100.0, debug build, DXC 1.9.0.5512 (
dxcon PATH). Detached checkout of the PR head; the merge base iscbc296a, so it does not includeea088a5, and I did not merge it with currentmain.Targeted (
cargo test -p xcl --lib -- gpu_abs_neg_on_move_select_and_conversions --nocapture --test-threads=1):XCL_DIRECT_DXIL=0: 1 passed, 0 failed, 0 ignoredXCL_DIRECT_DXIL=1: 1 passed, 0 failed, 0 ignoredAll
gpu_lib tests (cargo test -p xcl --lib -- gpu_ --test-threads=1):XCL_DIRECT_DXIL=0: 135 passed, 1 failed, 1 ignored. The failure isgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722,res[30] = 0x1vs CPU0x7fffffff), the known RDNA3 failure onmain. The PR does not touch it.XCL_DIRECT_DXIL=1: 134 passed, 2 failed, 1 ignored. Failures: the samefuzz_validate_and_gpu_1, andgpu_image_get_resinfo_1d_array(lane 0 resinfo[4, 1, 1], expected[4, 3, 1]). The PR does not touch image resinfo. I did not run this test onmainunderXCL_DIRECT_DXIL=1, so I can't say whether it also fails there.Full suite (
cargo test --workspace --no-fail-fast -- --test-threads=4, env unset): 1154 passed, 1 failed, 46 ignored.fuzz_validate_and_gpu_1, as above), 26 ignored.SKIPPEDlines, all inlower_dxil::tests(f16 / f32 conversion programs refused by the per-lane form). These are not coverage.Not tested: retail title or
scripts/smoke.ps1, NVIDIA, Intel, Wine/vkd3d, this PR merged with currentmain,gpu_image_get_resinfo_1d_arrayonmainunderXCL_DIRECT_DXIL=1.AI use: this report was run and written by Claude Code (Claude Sonnet 5.5). I read the diff but did not change any code.
@futurepro62 on GitHub · 2026-11-26 08:51 UTC · original
NVIDIA and AMD full-suite run, to go with the reports above by oni-swr, since none of them covers NVIDIA. Tested exact head
fed16e7d(on its basecbc296a).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1143 passed, 0 failed, 44 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.gpu_abs_neg_on_move_select_and_conversions.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1154 passed, 0 failed, 46 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on mainb49be183too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.