Direct DXIL: fold Countbits of constants (AMD folds Bfrev(Countbits(K)) wrong) #2221

Open
Diskuss wants to merge 1 commit from upstream-pr/2231 into main
Diskuss commented 2026-11-25 10:49:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Diskuss on 2026-11-25T10:49:05Z.


On the RX 9070 XT (RDNA4), the AMD driver (amdxc64) folds Bfrev(Countbits(K)) wrong when K is a constant. It gives bfrev(n) | n (n = countbits(K)): for K = 2 that is 0x80000001 instead of 0x80000000. This is the cause of fuzz seed 1599 (62 mismatches) and of fuzz_validate_and_gpu_3 failing on this card. Shader::bit_count now folds Countbits of a constant itself, so the driver never sees that pattern. The reduced HLSL repro and the analysis are in https://github.com/xcl-dev/xcl/issues/2115#issuecomment-7156460558.

Part of #2115

What is in it

  • crates/xcl/src/gpu/dxil/module.rs: Module::int_const, which reads the value of an integer constant.
  • crates/xcl/src/gpu/dxil/ops.rs: Shader::bit_count folds Countbits of a constant, masked to the operand's width.
  • crates/xcl/src/gpu/dxil/ops_tests.rs: new test bfrev_of_countbits_of_a_constant_matches_cpu, which compares the GPU result with the CPU.

Tested

  • AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029; Ryzen 7 5700X3D; Windows 11 Pro 26300.9974; Rust 1.100.0 msvc; DXC 1.9.2602.17; debug build for the tests, release build for the smoke runs.
  • cargo test -p xcl --lib -- --test-threads=4:
    • this PR (64eef49, on main 2898511): 1284 passed, 1 failed, 26 ignored.
    • main 2898511 on the same machine: 1282 passed, 2 failed, 26 ignored.
    • The difference: fuzz_validate_and_gpu_3 now passes, and the new test is counted.
    • The 1 failure also fails on main and is not touched here: fuzz_validate_and_gpu_1, seed 722, res[30] = 0x1, CPU 0x7fffffff. #2192 covers it.
  • bfrev_of_countbits_of_a_constant_matches_cpu and fuzz_validate_and_gpu_3 alone (--test-threads=1): both pass.
  • Fuzz seed 1599: 0 mismatches (was 62).
  • SKIPPED tests:
    • pso_measurement_compiles_an_exact_synthetic_record (Developer Mode is off).
    • 6 f16_programs_on_the_gpu/f32_programs_on_the_gpu per-lane cases (refused ops).
  • No device removal.

Regression run

main:

xcl-smoke v1
commit: 4d441866a42a0bca052044299f94ff1471a6523b
gpu: AMD Radeon RX 9070 XT
title: d5605821
seconds: 60
exit: 0xc0000005
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 0 0
device removals: 0
crashes: 2
peak commit: 866 MB

This PR:

xcl-smoke v1
commit: 64eef49e57698ef428941c75ab3b80ac817c8837
gpu: AMD Radeon RX 9070 XT
title: d5605821
seconds: 60
exit: 0xc0000005
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 2
peak commit: 866 MB

The title is The Matrix Awakens. On main (4d44186) and on this PR it dies the same way, about 1.5 to 3.5 s in: the title's CreateCommandSignature (DispatchIndirectMesh) fails, then it reads a null pointer (0xc0000005). That is fixed only in #1887. So this run shows no new crash and no device removal, but it never reaches a shader that this change affects.

Not tested

  • The other workspace crates after the rebase onto 2898511 (only -p xcl --lib was rerun; the change is in that crate).
  • A retail title that reaches the changed code. The smoke title crashes before that (see above).
  • Constants that the driver derives itself are not folded here, e.g. Countbits(zext((in & 0) | 2)). The translator does not see those as constants.
  • Other AMD generations, newer drivers, and NVIDIA/Intel. The fold gives the same value on any GPU.

AI use

  • Claude Code (Claude Opus 5.5): code, tests and description; reviewed by Diskuss.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5489850013 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2231). Originally posted by [Diskuss](https://github.com/Diskuss) on 2026-11-25T10:49:05Z. --- On the RX 9070 XT (RDNA4), the AMD driver (amdxc64) folds `Bfrev(Countbits(K))` wrong when `K` is a constant. It gives `bfrev(n) | n` (n = countbits(K)): for K = 2 that is 0x80000001 instead of 0x80000000. This is the cause of fuzz seed 1599 (62 mismatches) and of `fuzz_validate_and_gpu_3` failing on this card. `Shader::bit_count` now folds `Countbits` of a constant itself, so the driver never sees that pattern. The reduced HLSL repro and the analysis are in https://github.com/xcl-dev/xcl/issues/2115#issuecomment-7156460558. Part of #2115 **What is in it** - `crates/xcl/src/gpu/dxil/module.rs`: `Module::int_const`, which reads the value of an integer constant. - `crates/xcl/src/gpu/dxil/ops.rs`: `Shader::bit_count` folds `Countbits` of a constant, masked to the operand's width. - `crates/xcl/src/gpu/dxil/ops_tests.rs`: new test `bfrev_of_countbits_of_a_constant_matches_cpu`, which compares the GPU result with the CPU. **Tested** - AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029; Ryzen 7 5700X3D; Windows 11 Pro 26300.9974; Rust 1.100.0 msvc; DXC 1.9.2602.17; debug build for the tests, release build for the smoke runs. - `cargo test -p xcl --lib -- --test-threads=4`: - this PR (`64eef49`, on `main` `2898511`): **1284 passed, 1 failed, 26 ignored**. - `main` `2898511` on the same machine: 1282 passed, 2 failed, 26 ignored. - The difference: `fuzz_validate_and_gpu_3` now passes, and the new test is counted. - The 1 failure also fails on `main` and is not touched here: `fuzz_validate_and_gpu_1`, seed 722, `res[30] = 0x1, CPU 0x7fffffff`. #2192 covers it. - `bfrev_of_countbits_of_a_constant_matches_cpu` and `fuzz_validate_and_gpu_3` alone (`--test-threads=1`): both pass. - Fuzz seed 1599: 0 mismatches (was 62). - SKIPPED tests: - `pso_measurement_compiles_an_exact_synthetic_record` (Developer Mode is off). - 6 `f16_programs_on_the_gpu`/`f32_programs_on_the_gpu` per-lane cases (refused ops). - No device removal. **Regression run** `main`: ``` xcl-smoke v1 commit: 4d441866a42a0bca052044299f94ff1471a6523b gpu: AMD Radeon RX 9070 XT title: d5605821 seconds: 60 exit: 0xc0000005 frames shown: none logged (the run did not reach its end) presents per 2 s (last 3): 0 0 device removals: 0 crashes: 2 peak commit: 866 MB ``` This PR: ``` xcl-smoke v1 commit: 64eef49e57698ef428941c75ab3b80ac817c8837 gpu: AMD Radeon RX 9070 XT title: d5605821 seconds: 60 exit: 0xc0000005 frames shown: none logged (the run did not reach its end) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 2 peak commit: 866 MB ``` The title is The Matrix Awakens. On `main` (`4d44186`) and on this PR it dies the same way, about 1.5 to 3.5 s in: the title's `CreateCommandSignature` (DispatchIndirectMesh) fails, then it reads a null pointer (0xc0000005). That is fixed only in #1887. So this run shows no new crash and no device removal, but it never reaches a shader that this change affects. **Not tested** - The other workspace crates after the rebase onto `2898511` (only `-p xcl --lib` was rerun; the change is in that crate). - A retail title that reaches the changed code. The smoke title crashes before that (see above). - Constants that the driver derives itself are not folded here, e.g. `Countbits(zext((in & 0) | 2))`. The translator does not see those as constants. - Other AMD generations, newer drivers, and NVIDIA/Intel. The fold gives the same value on any GPU. **AI use** - Claude Code (Claude Opus 5.5): code, tests and description; reviewed by Diskuss. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DavidM1911 commented 2026-11-25 17:07:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T16:31:25Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: 1 real failure, deterministic (also fails --test-threads=1):
hle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa
  assertion failed: format 85 kept — left: 28, right: 85 (device_x.rs:1376)

Same failure as #2229 (likely the same feature branch area). Needs a fix before merge.

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7168115941 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2231#issuecomment-7168115941). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T16:31:25Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: **1 real failure**, deterministic (also fails `--test-threads=1`): ``` hle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa assertion failed: format 85 kept — left: 28, right: 85 (device_x.rs:1376) ``` Same failure as #2229 (likely the same feature branch area). Needs a fix before merge. — Devin
CharNoir commented 2026-11-25 23:09:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CharNoir on 2026-11-25T22:32:59Z.


Test report for 64eef49 ("Direct DXIL: fold Countbits of constants").

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, 16 GB), Adrenalin 26.11.2; AMD Ryzen 5 7600; Windows 11 Pro 25H2 (build 26200.9974); Rust <rustc --version>; debug (test profile); DXC 1.8.2502.11 (Windows SDK 10.0.26100.0)
  • cargo test -p xcl --lib fuzz_validate_and_gpu, on main and on this PR:
Commit _0 _1 _2 _3
main e1d84b7 ok FAIL (seed 722) ok FAIL (seed 1599: res[193] = 0x1, CPU 0x0)
PR 64eef49 ok FAIL (seed 722, unchanged) ok ok
  • Seed 1599 is fixed on RDNA4. The failing program computes Bfrev(Countbits(2)), which should be 0x80000000; the GPU result on main is consistent with the driver misfolding Bfrev(Countbits(K)). The remaining seed 722 failure (WaveReadLaneFirst before a divergent switch) is unrelated to this PR; #2192 targets it.
  • For reference, the full suite on main e1d84b7: cargo test --workspace -- --test-threads=4: 1421 passed, 2 failed (the two fuzz tests above), 46 ignored. SKIPPED GPU tests: 6 f16/f32 per-lane refusals (#1426) and the heap_window test ("no heap windows").

Not tested

  • The full suite on this PR's commit: only the fuzz_validate_and_gpu tests were run on it.
  • scripts/smoke.ps1 regression run on a real title.
  • Non-AMD GPUs.

AI use

  • Claude (Claude Sonnet 5.5) assembled this report from the logs of the runs above. I ran the commands on the hardware named.
<!-- greyfinch-sync:ivall/xcl:comment:7176500939 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2231#issuecomment-7176500939). Originally posted by [CharNoir](https://github.com/CharNoir) on 2026-11-25T22:32:59Z. --- Test report for 64eef49 ("Direct DXIL: fold Countbits of constants"). **Tested** - Hardware: AMD Radeon RX 9070 XT (RDNA4, 16 GB), Adrenalin 26.11.2; AMD Ryzen 5 7600; Windows 11 Pro 25H2 (build 26200.9974); Rust `<rustc --version>`; debug (`test` profile); DXC 1.8.2502.11 (Windows SDK 10.0.26100.0) - `cargo test -p xcl --lib fuzz_validate_and_gpu`, on main and on this PR: | Commit | `_0` | `_1` | `_2` | `_3` | |---|---|---|---|---| | main e1d84b7 | ok | FAIL (seed 722) | ok | **FAIL** (seed 1599: `res[193] = 0x1`, CPU `0x0`) | | PR 64eef49 | ok | FAIL (seed 722, unchanged) | ok | **ok** | - Seed 1599 is fixed on RDNA4. The failing program computes `Bfrev(Countbits(2))`, which should be `0x80000000`; the GPU result on main is consistent with the driver misfolding `Bfrev(Countbits(K))`. The remaining seed 722 failure (WaveReadLaneFirst before a divergent switch) is unrelated to this PR; #2192 targets it. - For reference, the full suite on main e1d84b7: `cargo test --workspace -- --test-threads=4`: 1421 passed, 2 failed (the two fuzz tests above), 46 ignored. SKIPPED GPU tests: 6 f16/f32 per-lane refusals (#1426) and the heap_window test ("no heap windows"). **Not tested** - The full suite on this PR's commit: only the `fuzz_validate_and_gpu` tests were run on it. - `scripts/smoke.ps1` regression run on a real title. - Non-AMD GPUs. **AI use** - Claude (Claude Sonnet 5.5) assembled this report from the logs of the runs above. I ran the commands on the hardware named.
DavidM1911 commented 2026-11-26 01:05:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T00:59:26Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7179314687 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2231#issuecomment-7179314687). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T00:59:26Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
upipibi commented 2026-11-26 16:25:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T16:25:22Z.


@Diskuss a sibling of this fold, for NVIDIA: on an RTX 3070 (driver 616.56) a FirstbitLo / FirstbitHi of a constant ANDed with a product of odd values reads bit 0 as 0 on the direct path (found by fuzzing main). Countbits of the same constant comes out right there, so this PR's fold doesn't cover it, but the fix belongs in the same Shader::bit_count: fold FirstbitLo/FirstbitHi of a 32-bit constant with Module::const_u64, next to your Countbits arm.

A change on top of main 8b957bec with a GPU test is on a branch you are welcome to take into this PR: github.com/upipibi/xcl@b6406763 (ops.rs +13, core_tests.rs test gpu_direct_bit_scan_of_a_constant_and_an_odd_product over s_ff1_b32, s_ff1_b64, s_flbit, v_ffbl, v_ffbh).

RTX 3070 8 GB, driver 616.56, Windows 11, debug: the test fails 3/3 on main (every case 0 instead of 1) and passes 3/3 with the change; cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4 with it: 1311 passed, 0 failed, 27 ignored. Not tested: AMD/Intel, a title run.

AI-assisted (Claude Code, Claude Opus 5.5): found it by fuzzing, wrote the change and test, ran them, wrote this.

<!-- greyfinch-sync:ivall/xcl:comment:7197624794 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2231#issuecomment-7197624794). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-26T16:25:22Z. --- @Diskuss a sibling of this fold, for NVIDIA: on an RTX 3070 (driver 616.56) a FirstbitLo / FirstbitHi of a constant ANDed with a product of odd values reads bit 0 as 0 on the direct path (found by fuzzing `main`). `Countbits` of the same constant comes out right there, so this PR's fold doesn't cover it, but the fix belongs in the same `Shader::bit_count`: fold `FirstbitLo`/`FirstbitHi` of a 32-bit constant with `Module::const_u64`, next to your `Countbits` arm. A change on top of `main` `8b957bec` with a GPU test is on a branch you are welcome to take into this PR: https://github.com/upipibi/xcl/commit/b6406763 (`ops.rs` +13, `core_tests.rs` test `gpu_direct_bit_scan_of_a_constant_and_an_odd_product` over `s_ff1_b32`, `s_ff1_b64`, `s_flbit`, `v_ffbl`, `v_ffbh`). RTX 3070 8 GB, driver 616.56, Windows 11, debug: the test fails 3/3 on `main` (every case 0 instead of 1) and passes 3/3 with the change; `cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4` with it: 1311 passed, 0 failed, 27 ignored. Not tested: AMD/Intel, a title run. AI-assisted (Claude Code, Claude Opus 5.5): found it by fuzzing, wrote the change and test, ran them, wrote this.
Granite900 commented 2026-11-26 16:26:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Granite900 on 2026-11-26T16:26:05Z.


Tested 64eef49e (this PR's head) against main on an RX 9070 XT.

Tested

  • AMD Radeon RX 9070 XT (RDNA4), Adrenalin 26.11.2, Windows 11, rustc 1.100.0, debug
  • DXC: dxcompiler 1.9.2609.5 (also ran with SDK 1.8.2502.11, same results)
  • cargo test -p xcl --lib gpu::dxil::fuzz_tests
    • main: fuzz_validate_and_gpu_1 (seed 722) and fuzz_validate_and_gpu_3 (seed 1599) both fail, reproducibly. Seed 1599: res[193] = 0x1, CPU 0x0
    • 64eef49e: 4 passed, 1 failed, 2 ignored. Seed 1599 is fixed (fuzz_validate_and_gpu_3 passes).

Still failing: seed 722, unchanged: res[30] = 0x1, CPU 0x7fffffff. With this PR the Countbits in the 227944867 case is folded away (that block is empty in the disassembly), and it still fails. So seed 722 doesn't look like the Bfrev(Countbits(K)) pattern, and #2115 stays open. The remaining suspect is the switch/phi path that carries the WaveReadLaneFirst result (%10) through case 1 and the default.

Not tested

  • the full suite on this commit (on main: 1315 passed, 3 failed: the two fuzz seeds, plus pso_measurement_compiles_an_exact_synthetic_record, which needs Developer Mode)
  • retail titles
  • other GPUs

AI use: report drafted with Claude (Claude Opus 5.5) from my test runs.

<!-- greyfinch-sync:ivall/xcl:comment:7197640262 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2231#issuecomment-7197640262). Originally posted by [Granite900](https://github.com/Granite900) on 2026-11-26T16:26:05Z. --- Tested `64eef49e` (this PR's head) against `main` on an RX 9070 XT. **Tested** - AMD Radeon RX 9070 XT (RDNA4), Adrenalin 26.11.2, Windows 11, rustc 1.100.0, debug - DXC: dxcompiler 1.9.2609.5 (also ran with SDK 1.8.2502.11, same results) - `cargo test -p xcl --lib gpu::dxil::fuzz_tests` - `main`: `fuzz_validate_and_gpu_1` (seed 722) and `fuzz_validate_and_gpu_3` (seed 1599) both fail, reproducibly. Seed 1599: `res[193] = 0x1, CPU 0x0` - `64eef49e`: 4 passed, 1 failed, 2 ignored. **Seed 1599 is fixed** (`fuzz_validate_and_gpu_3` passes). **Still failing:** seed 722, unchanged: `res[30] = 0x1, CPU 0x7fffffff`. With this PR the Countbits in the `227944867` case is folded away (that block is empty in the disassembly), and it still fails. So seed 722 doesn't look like the Bfrev(Countbits(K)) pattern, and #2115 stays open. The remaining suspect is the switch/phi path that carries the `WaveReadLaneFirst` result (`%10`) through `case 1` and the default. **Not tested** - the full suite on this commit (on `main`: 1315 passed, 3 failed: the two fuzz seeds, plus `pso_measurement_compiles_an_exact_synthetic_record`, which needs Developer Mode) - retail titles - other GPUs **AI use:** report drafted with Claude (Claude Opus 5.5) from my test runs.
Luislariosss commented 2026-11-26 21:57:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Luislariosss on 2026-11-26T21:57:22Z.


Tested 64eef49 with #2192 and #1946 merged on top of main 8b957be, on an RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010:

  • cargo test -p xcl --lib: 1320 passed, 0 failed, 27 ignored (on main alone here: 1316 passed, 2 failed). fuzz_validate_and_gpu_1 (seed 722) and _3 (seed 1599) pass with the stack.
  • gpu::dxil::fuzz_tests::amd_reduced_seeds -- --ignored: 6 of 7 variants pass.

The one that still fails, deterministically (two runs), is the dynamic form of the shape this PR folds:

FAIL 1599 Countbits.i64(dynamic 2) -> shift / Bfrev: res[1] = 0x1, CPU 0x0

PASS full seed 1599: 0 mismatching dwords with the stack, so the seed itself is covered. The failing variant differs only in building the operand at runtime (in[lane] & 0 | 2, opaque to the driver) instead of C(T::I64, 2). Posting it here in case it belongs in this PR or in a follow-up. Details and the full run in #2115.

<!-- greyfinch-sync:ivall/xcl:comment:7204220359 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2231#issuecomment-7204220359). Originally posted by [Luislariosss](https://github.com/Luislariosss) on 2026-11-26T21:57:22Z. --- Tested `64eef49` with #2192 and #1946 merged on top of `main` `8b957be`, on an **RX 9060 XT 16 GB** (RDNA4), driver `32.0.32029.2010`: - `cargo test -p xcl --lib`: 1320 passed, 0 failed, 27 ignored (on `main` alone here: 1316 passed, 2 failed). `fuzz_validate_and_gpu_1` (seed 722) and `_3` (seed 1599) pass with the stack. - `gpu::dxil::fuzz_tests::amd_reduced_seeds -- --ignored`: 6 of 7 variants pass. The one that still fails, deterministically (two runs), is the dynamic form of the shape this PR folds: ``` FAIL 1599 Countbits.i64(dynamic 2) -> shift / Bfrev: res[1] = 0x1, CPU 0x0 ``` `PASS full seed 1599: 0 mismatching dwords` with the stack, so the seed itself is covered. The failing variant differs only in building the operand at runtime (`in[lane] & 0 | 2`, opaque to the driver) instead of `C(T::I64, 2)`. Posting it here in case it belongs in this PR or in a follow-up. Details and the full run in #2115.
github-actions[bot] commented 2026-12-01 02:35:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:35:54Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7298788619 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2231#issuecomment-7298788619). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-12-01T02:35:54Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 07:38:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:38:25Z.


Triage (#1607) – head 64eef49

#3225 targets the same AMD fault (fuzz seed 1599, #2115) another way. It replaces every Bfrev.i32 with the shift-and-mask sequence (bfrev32_shifts). This PR folds Countbits of constants in Shader::bit_count, so it only covers a constant operand. The dynamic variant in fuzz_tests.rs (1599 Countbits.i64(dynamic 2) -> shift / Bfrev) is not covered by this fold.
The fold itself looks right: int_const returns the sign-extended value, which is masked to the operand width before count_ones. #2124 (same issue) is only test tooling.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7304302871 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2231#issuecomment-7304302871). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:38:25Z. --- **Triage (#1607)** – head 64eef49 #3225 targets the same AMD fault (fuzz seed 1599, #2115) another way. It replaces every `Bfrev.i32` with the shift-and-mask sequence (`bfrev32_shifts`). This PR folds `Countbits` of constants in `Shader::bit_count`, so it only covers a constant operand. The dynamic variant in `fuzz_tests.rs` (`1599 Countbits.i64(dynamic 2) -> shift / Bfrev`) is not covered by this fold. The fold itself looks right: `int_const` returns the sign-extended value, which is masked to the operand width before `count_ones`. #2124 (same issue) is only test tooling. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2231:upstream-pr/2231'
git switch 'upstream-pr/2231'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2231'
git switch 'upstream-pr/2231'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2231'
git switch 'upstream-pr/2231'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2231'
git switch 'main'
git merge --squash 'upstream-pr/2231'
git switch 'main'
git merge --ff-only 'upstream-pr/2231'
git switch 'main'
git merge 'upstream-pr/2231'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2221
No description provided.