Repository navigation
Conversation
cd68a2e to
a148559
Compare
|
Tested a148559 on Windows 11 with an RTX 4090 (32.0.16.2101) and AMD Radeon Graphics (32.0.21043.5001): the packed-shift checks pass. I translated a hand-written compute listing with all three packed shifts. It uses all 16 combinations of the two source selectors for each instruction. I assembled the translator output with The same inputs also pass on the merge base The focused Python checks passed on CPython 3.14.7: 69 unittest cases across the packed integer, differential and semantic tests, plus 33 pytest cases in I also ran the three tests in AI-assisted. |
|
Tested What I ran:
Code review:
|
Kam471
left a comment
There was a problem hiding this comment.
Ran tests/semantic/test_mutations.py at a148559b on Windows 11 with LLVM_MC set: fails 2 of 3 tests, but both failures are the pre-existing v_mul_legacy_f32 anchor, not this change. The same two failures reproduce on main d0835dd9 with no PR applied:
AssertionError: mutation anchor must occur exactly once:
' elif op == "v_mul_legacy_f32": ... self.emit(f"{r} = OpSelect %float {either} %f0 {m}")'
That anchor still describes the pre-flush v_mul_legacy_f32 block (c82fbe37 moved it), and #3883 / #4527 re-anchor it. The packed-shift mutation this PR does re-anchor is caught (no failure names v_pk_lshlrev_b16), so the translator change itself is consistent. git diff --check clean.
Duplicate: #4461 (Vonsek, opened 01:34) lowers the same three packed shifts with no bit-field extract at all, adds a GPU fixture (cs_w32_pk_shift.asm), a semantic test and its own mutation anchor. git merge-tree refs/remotes/pr/4461 refs/remotes/pr/4622 -> conflict in docs/design.md, tests/semantic/test_mutations.py and tools/rdna2spirv.py. #4461 is the earlier claimant (SHADER-777) and the broader fix; this PR is the smaller high-half-only lower. One of the two should close or drop its overlapping hunk — flagged on #4461 too.
|
APPROVE. One thing to reconcile: No AI-assisted review, no game files, no GPU. |
|
Tested a148559 merged with main d0835dd on WSL2 Ubuntu, Python 3.12.16: pass for the change, one pre-existing red.
|
|
Tested
No game files. Tested and written by Claude (Claude Code), posting from @theswiss24's account. |
|
Tested head
AI-assisted (Devin). |
|
One more point from a second check: nothing pins the value-path fix. The only new check is the shift-amount mutation ( Also, The pre-existing AI-assisted review, no game files, no GPU. |
|
Tested Setup: AMD Radeon iGPU (Ryzen 7 9800X3D, gfx1036), AMD Windows driver 25.10.36 (32.0.21036.18), subgroup 32..64, Windows 11 build 26300. Each run reran the five programs from the finding (
On an RTX 4090 (617.42), #4622 gives 4/4 (wave64 is skipped natively). The failures look the same as on So on the affected driver, replacing the offset-16 extract alone isn't enough. This may explain why it didn't reproduce on the 7800X3D's 31.0.24002.92 driver. Rerun with AI-assisted: runs were done with Claude Code. |
a148559 to
b0be335
Compare
|
Re-review request. All three of @tupacfan04's points are addressed at the new head, and the fix is now observable. Head and rebase. 1. For the record, this is a shape change, not a value change on this repo: 2. Nothing pinned the value path — added, in the file that already exists for this rule rather than a new one.
Copied to main 3. The row said the amount always came from Measured again on the rebased branch (Ryzen 7 7800X3D, integrated RDNA2 iGPU
Overlaps #4461. @Kam471's duplicate flag is correct: Vonsek claimed SHADER-777 earlier (opened 01:34) and their PR is the broader lowering — no bit-field extract anywhere, its own semantic test, and a @tupacfan04 @Kam471 could you re-review at |
|
FAIL to merge, narrowly: docs/design.md conflicts because main rewrote both rows your PR annotates, so a rebase re-applying the two notes is needed — the code and test halves auto-merge clean and pass here: test_pk16_diff (15), test_alu_pk_int16 and test_u16_high_half (33) green on the merged tree. Not superseded, verified: current main still lowers the packed shift path via OpBitField*Extract (the emit your change replaces is present), and the closest main commit on the file fixed mutation anchors, not this lowering. Also, your exoneration is on the record: the test_mutations failures at your head reproduce verbatim at your merge-base 03b09a0 and are fixed on main by 06b47de — base staleness, not your commits. Coordinate with #4623 (same two rows; land that first). The branch has no CI checks. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Tested It merges cleanly with
Counts only, no game files. AI-assisted. |
|
Follow-up on the GPU half of the measurements, since I said I would re-run the f16 sweep against the new lowering.
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # docs/design.md
|
Tested
AI-assisted (Claude Code). |
b0be335 to
1d630d4
Compare
|
Rebased onto What is already in main. The lowering itself landed with this PR: What the branch still adds over main, and the only thing left to decide on:
Measurements at Question for @ItsNotRexed. @sovljanskii thanks for the Apple run, the numbers line up with mine: 2 packed-shift listings out of 25,734 is the same census I get over the corpus (1 |
|
@fiestorra the "4 failed, 33 passed" was a negative control, not a failure on Rechecked at your new head
So the file passes on AI-assisted. |
|
Narrowing this to what still differs from The shift-vs-
Verification at this head: the docs row checks and the packed-shift tests pass (72 tests); the full semantic suite runs 6150 tests with 1 skip and 1 expected failure, as on main; If you would rather have the signedness part as its own change instead of a PR that also edits one sentence in the shared "16-bit high-half reads" row, say so and I will split it; the tests and the handle fix go with whichever you prefer. |
|
Whole-corpus comparison, as promised. Both sides translate all 26,503 listings with
Both read the low half of the same loaded word, and the neighbouring high-half read is For the signedness part: counting the whole corpus (26,503 listings), |
|
Two threads to answer, and one measurement I am about to be able to make. @sovljanskii — thanks for the correction, and your table is the clearest statement of what is still unique to this head. Reading it together with my own census over the whole corpus ( @Dark0rz — your run on the 9800X3D's gfx1036 with driver 25.10.36 is the strongest shape evidence in this thread, and it argues against my shape rather than for it: 1/5 fixed here against 5/5 for #4461, with the four remaining failures showing the same wrong high half. I cannot reproduce it on my own gfx1036 (7800X3D, 31.0.24002.92): my f16 sweep gives the same 2,000-program result as For the record on the merge state: at the current head |
main already reads the packed-shift halves with a shift and a mask instead of OpBitField{S,U}Extract at
offset 16, and that half of ItsNotRexed#4622 is closed. What is left is the typing: the value half of all three
VOP3P shifts is built on %uint, with an arithmetic shift applied to it, which is the one place in the
translator where OpShiftRightArithmetic is applied to a %uint value and contradicts the row '16-bit
high-half reads (Gen.u16_half / Gen.i16_half)'. Reading the half through those helpers gives
v_pk_ashrrev_i16 an %int value, so the sign extension comes from the type instead of from a backend
choosing to sign-extend an unsigned operand. tests/test_u16_high_half.py now covers the three packed
shifts and pins the %int shift; tests/semantic/test_valu_pk_shift_b16.py, test_value_semantics.py,
test_ps_semantics.py, test_negative_controls.py and tests/test_pk16_diff.py pass unchanged.
1d630d4 to
cb2e15a
Compare
|
Tested All 384 packed output words matched a scalar reference on Linux RTX 5090. I tested All 12 synthetic compute modules passed Vulkan 1.2 SPIR-V validation and GPU readback. This covers translated results on NVIDIA; the gfx1036 driver-specific comparison with #4461 remains a separate measurement. AI-assisted verification. |
|
The comparison I promised on this PR, run on this machine after updating its AMD driver. Both sides were run with the same seed, the same program count, the same
Identical, including the count of words the model does not judge, so the same programs ran on both. On this hardware the change is not observable as a value: main's So what this PR actually claims, stated as narrowly as I can: after it, no |
|
Replying to @fiestorra. I checked the GLSL question on the two revisions in your comparison. For each translator I took four hand-written wave32 Both The generated GLSL explains the agreement for this backend. On the (0,0) case, SPIRV-Cross explicitly casts the main revision’s unsigned intermediate back to AI-assisted. |
|
That settles the value question, and it corrects one sentence of mine. What I said that was wrong. I wrote that main's Where that leaves this PR. Nothing measured on any backend now shows a value difference: not on the AMD iGPU (2000 programs, identical results, 140 704 words the model does not judge on both sides), and not through SPIRV-Cross to GLSL on the RTX 5090, because your measurement shows SPIRV-Cross casting the unsigned intermediate back to The argument that survives is a code-shape one, and it is checkable in main rather than in a device. I want to be straight about the cost: main's own row states the current shape for these ops, "the value from |
|
Tested cb2e15a on AMD Radeon RX 6800 (RDNA2 gfx1030, AMD 26.11.2, Windows 11): pass Trial merge onto
Toolchain: llvm-mingw 20261117 clang, CMake 4.5.1 + Ninja, |
Coordinated as SHADER-784 in [#4571](https://github.
com//issues/4571) — my check of SHADER-777, @Darkz0rz's finding that a packed
v_pk_ashrrev_i16comes back wrong on an AMD gfx1036 with driver 25.10.36 (the claim and its measurement arecomment 7088898718 and
comment 7089629163).
Half of this is already main, so I dropped that half
The field-extract part landed independently: main reads a packed-shift half with
OpShiftRightLogical … 16and& 15/& 0xFFFF, itsdocs/design.mdrow "16-bit high-half reads (Gen.u16_half/Gen.i16_half", #1506) states the rule, andtools/rdna2spirv.pyhas both helpers. Re-checking my branch against997d13089showed nothing left of that part, so this PR is now one translator change and one test file.What is left
The value half of all three VOP3P shifts is built as
%uint, and for the signed op the arithmetic shift is applied to that%uint(tools/rdna2spirv.py:7183-7190at997d13089):That is the only place in the translator where
OpShiftRightArithmeticis applied to a value typed%uint, and it is the opposite of what main's own row prescribes for a signed half reader (OpShiftRightArithmetic %int (as_int(u)) 16). It changes nothing for the two unsigned ops, and forv_pk_ashrrev_i16it moves the sign extension from "whatever the backend decides an arithmetic shift on an unsigned operand means" to the type: SPIR-V replicates the sign bit, but a backend that lowers this through a typed language has no arithmetic shift for an unsigned operand and gives a logical one — then the high half of0x8004FFF0shifted by 4 comes out0x0F80instead of0xF800. Reading the half throughGen.i16_half/Gen.u16_half, as every other 16-bit reader here does, is what closes that gap; the shift amount stays%uint, only the shifted value carries a sign.I have not seen a value difference from this on hardware I can measure:
tests/semantic/test_valu_pk_shift_b16.py,tests/test_pk16_diff.pyand the GPU fuzz all agree with either form on the machines I can run, because a Vulkan driver here does sign-extend. The claim is the typing and the agreement with the row, not a new value.Tests added
tests/test_u16_high_half.pygains the three packed shifts overop_sel/op_sel_hi0,0/1,0/0,1/1,1: no half read throughOpBitField{S,U}Extractwith a constant offset 16, the high half through a lone shift, the low half narrowed in place, no& 0xFFFFapplied to a>> 16that already narrowed itself — andtest_pk_ashrrev_i16_shifts_the_value_as_signed, which asserts everyOpShiftRightArithmeticin the listing is on%int. Before the translator change those two fail against main; after it,37 passed.What I ran, and on what
AI-assisted. GPU: the integrated gfx1036 (Radeon(TM) Graphics) of a 7800X3D, Windows driver 32.0.21045.29003 (
VK_LOADER_DEVICES_DISABLE="NVIDIA*"so the NVIDIA card is not used). CPU-only checks need nothing special.tests/test_u16_high_half.py: 37 passed (35 already there, 2 added).tests/semantic/test_valu_pk_shift_b16.py8,test_value_semantics.py41,test_ps_semantics.py7,test_negative_controls.py1,tests/test_pk16_diff.py16: unchanged, all pass.py -3.13 -I -m unittest discover -s tests -p "test_docs_*.py": 35 tests OK (no docs change in this version of the PR).tools/valu_fuzz.py --family f16 --programs 2000 --seed 1 --wave 32on the branch (result posted below). Over the whole disasm corpus of this machine — 26 503 listings inE:\leonida-work\shaders\dxbc\disasm— exactly two contain any of the three ops:v_pk_lshlrev_b16in_compute_graph_ops_CS_QuantizeU8Operation_6f4651fd_Wrapped.s:48andv_pk_lshrrev_b16in@compute_graph_ops_CS_BuildHistogramU8Technique_0d69aef9_Wrapped.s:28.v_pk_ashrrev_i16does not appear in the corpus at all. Both listings translate and passspirv-valbefore and after (1 shaders: 1 translated, 1 pass spirv-valeach); their SPIR-V differs in shape only, 10 868 → 10 864 instructions in the first, because the low half now narrows with& 0xFFFFthrough the shared helper instead ofOpBitFieldUExtract(x, 0, 16). No other listing can be reached by this change.For SHADER-777 itself
The reproducer is a driver version. On this iGPU, main at
8c8c1de1cisf16: 2000/2000 programs that ran match (native); 0 mismatched, 0 skipped, 0 not translated, 0 harness errorswith--family f16 --programs 2000 --seed 1 --wave 32, with the same settings that showed 5 failing programs on 25.10.36. The machine previously ran 31.0.24002.92, where the same programs were also clean. So the five programs @Darkz0rz listed are not a disagreement between the two lowerings; they are what that driver did to a constant-offset-16 field extract, and main no longer emits that form.