shader: lower s_pack_ll/lh/hh_b32_b16 #89

Closed
lcg007xd-c wants to merge 0 commits from upstream-pr/89 into main
lcg007xd-c commented 2026-11-25 22:22:43 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by lcg007xd-c on 2026-11-25T22:22:43Z.


What is broken

The scalar packs decode, but a program using one fails to translate with s_pack_ll_b32_b16 is not supported (or the matching name):

SOP2 opcode Instruction
0x32 s_pack_ll_b32_b16
0x33 s_pack_lh_b32_b16
0x34 s_pack_hh_b32_b16

Compilers use them to build packed 16-bit constants and operands for the v_pk_* instructions.

How I found them: I translated, through the CPU harness of #62, a one-instruction program for every SOP1 and SOP2 opcode the decoder names, with the result in s12. The scout coverage run used s10, which overlaps the program's UAV descriptor in s[8:11], so it reported nearly every scalar op as "a descriptor changed after loading". With s12, 50 scalar opcodes turn out to be refused, and these three are among them.

Semantics

AMD's RDNA2 ISA (§12.1, opcodes 50–52):

  • s_pack_ll_b32_b16: D = {S1[15:0], S0[15:0]}
  • s_pack_lh_b32_b16: D = {S1[31:16], S0[15:0]}
  • s_pack_hh_b32_b16: D = {S1[31:16], S0[31:16]}

They write no SCC. The IR's writes_scc already leaves them out.

The change (emit/lower.rs, in sop)

Each source's named half is masked or shifted into place, and the two are ORed.

Tests

  • emit::lower::tests::scalar_packs_translate (every host): all three decode, and a program that moves the result to v0 and stores it translates. Without the lower.rs change it fails: s_pack_ll_b32_b16 [990c0100, 7e00020c]: GFX10 code at 0x24: s_pack_ll_b32_b16 is not supported.
  • valu_tests::scalar_packs_take_the_halves_their_names_say (Windows/GPU): two hand-computed cases per opcode.
  • CPU run: I ran these on Linux through the CPU harness of #62, which runs the emitted DXIL with LLVM's lli. I compared against a Rust reference on 60 scrambled pairs per opcode, also with src0 an inline constant (−1) and a 32-bit literal. All match.

Run here (Linux, Rust 1.98.1):

  • cargo test -p victory-shader --lib --locked: 188 passed, 0 failed, 2 ignored.
  • Portable clippy and CARGO_FEATURE_PURE=1 cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc -- -D warnings: clean.

Not run here: the GPU case, since I have no Windows machine.

🤖 Generated with Claude Code

<!-- greyfinch-sync:uiliannn/VItoriaBr:issue:5500196495 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VitoriaBr2.0/pull/89). Originally posted by [lcg007xd-c](https://github.com/lcg007xd-c) on 2026-11-25T22:22:43Z. --- ## What is broken The scalar packs decode, but a program using one fails to translate with `s_pack_ll_b32_b16 is not supported` (or the matching name): | SOP2 opcode | Instruction | |---|---| | 0x32 | `s_pack_ll_b32_b16` | | 0x33 | `s_pack_lh_b32_b16` | | 0x34 | `s_pack_hh_b32_b16` | Compilers use them to build packed 16-bit constants and operands for the `v_pk_*` instructions. **How I found them:** I translated, through the CPU harness of #62, a one-instruction program for every SOP1 and SOP2 opcode the decoder names, with the result in `s12`. The scout coverage run used `s10`, which overlaps the program's UAV descriptor in `s[8:11]`, so it reported nearly every scalar op as "a descriptor changed after loading". With `s12`, 50 scalar opcodes turn out to be refused, and these three are among them. ## Semantics AMD's RDNA2 ISA (§12.1, opcodes 50–52): - `s_pack_ll_b32_b16`: `D = {S1[15:0], S0[15:0]}` - `s_pack_lh_b32_b16`: `D = {S1[31:16], S0[15:0]}` - `s_pack_hh_b32_b16`: `D = {S1[31:16], S0[31:16]}` They write no SCC. The IR's `writes_scc` already leaves them out. ## The change (`emit/lower.rs`, in `sop`) Each source's named half is masked or shifted into place, and the two are ORed. ## Tests - **`emit::lower::tests::scalar_packs_translate`** (every host): all three decode, and a program that moves the result to `v0` and **stores** it translates. Without the `lower.rs` change it fails: `s_pack_ll_b32_b16 [990c0100, 7e00020c]: GFX10 code at 0x24: s_pack_ll_b32_b16 is not supported`. - **`valu_tests::scalar_packs_take_the_halves_their_names_say`** (Windows/GPU): two hand-computed cases per opcode. - **CPU run:** I ran these on Linux through the CPU harness of #62, which runs the emitted DXIL with LLVM's `lli`. I compared against a Rust reference on 60 scrambled pairs per opcode, also with src0 an inline constant (−1) and a 32-bit literal. All match. **Run here** (Linux, Rust 1.98.1): - `cargo test -p victory-shader --lib --locked`: 188 passed, 0 failed, 2 ignored. - Portable clippy and `CARGO_FEATURE_PURE=1 cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc -- -D warnings`: clean. **Not run here:** the GPU case, since I have no Windows machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lmouz823-lang commented 2026-11-28 08:26:11 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by lmouz823-lang on 2026-11-28T08:26:11Z.


I can take native Windows GPU validation at exact head eb43d9711a91abdec336479bd6dd448b02ec25a2. I will run both existing regressions, add focused fixed-expectation halfword, SCC-preservation and inline/literal controls where coverage is missing, and verify a targeted negative control followed by fresh restored-source runs. RTX 4060 Laptop and WARP runs will use the SDK validator. Exact counts, skipped cases and remaining native AMD/game scope will accompany the small patch. AI-assisted with Codex.

<!-- greyfinch-sync:uiliannn/VItoriaBr:comment:7236581355 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/89#issuecomment-7236581355). Originally posted by [lmouz823-lang](https://github.com/lmouz823-lang) on 2026-11-28T08:26:11Z. --- I can take native Windows GPU validation at exact head `eb43d9711a91abdec336479bd6dd448b02ec25a2`. I will run both existing regressions, add focused fixed-expectation halfword, SCC-preservation and inline/literal controls where coverage is missing, and verify a targeted negative control followed by fresh restored-source runs. RTX 4060 Laptop and WARP runs will use the SDK validator. Exact counts, skipped cases and remaining native AMD/game scope will accompany the small patch. AI-assisted with Codex.
lmouz823-lang commented 2026-11-28 08:54:14 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by lmouz823-lang on 2026-11-28T08:54:14Z.


Windows acceptance and a small regression test

Tested PR #89 at eb43d9711a91abdec336479bd6dd448b02ec25a2, based on 2b33e081ed7831f49610b747a508fb56d3cb3aa9.

The existing scalar-pack translation and GPU tests pass. The attached test also passes and adds SCC retention, contrasting halfwords, and constant-source coverage for all three scalar packs. This is an AI-assisted contribution with local Windows execution and independent review of the fixed expected values.

Environment and actual execution

  • Windows build 26200, Rust 1.98.1, NVIDIA RTX 4060 Laptop GPU with 8188 MiB and driver 610.88.
  • D3D12 hardware and Microsoft Basic Render Driver / WARP both executed the selected GPU tests. VICTORY_STRICT_TESTS=1 was enabled, with an explicit Windows SDK VICTORY_DXIL path. Each final exact invocation ran one test and reported one pass, zero failures and zero ignored tests. No selected test was skipped.
  • SDK dxil.dll was version 1.8.2502.11 from SDK 10.0.26100.0. Its SHA256 was 77e039c905030a641e53658a008b74e90635a5ea9b6b79eabd0f2003bdfca59a.
  • Temporary markers inside the existing VALU validator branch recorded successful SDK load, validation and matching DXIL container hash for 18 new-test modules and 3 original-test modules. These diagnostic runs exercised the same new test body and validator helper. The markers were removed before the final source was compiled and retested. The later final-source adjustment moved the original compare documentation to its correct test.
  • The final patch source was actually recompiled with cargo test --release --locked -p victory-shader --lib --no-run, completing in 1m10s. The two GPU exacts and the translation exact were then rerun against that final executable.

Added coverage

scalar_packs_preserve_scc_with_register_and_constant_sources uses fixed expected values for SOP2 0x32/0x33/0x34. The selected halves follow AMD's RDNA2 SOP2 opcodes 50–52. AMD RDNA2 ISA

  • Register pairs include zero, all ones, 12345678/9ABCDEF0, and FFFF0000/0000FFFF. The distinctive pair gives LL DEF05678, LH 9ABC5678, and HH 9ABC1234.
  • Both incoming SCC values are established dynamically using s_add_u32 s14, s3, 1. The test separately reads the pack result and SCC through s_cselect_b32 s15, 1, 0.
  • Source0 additionally covers inline -1 and a real 32-bit literal 89ABCDEF, with source1 12345678, under both incoming SCC values. The expected constant results are fixed in the test.
  • There are 96 checked register-source dispatches and 48 constant-source dispatches across hardware and WARP, giving 144 dispatches from 18 generated modules. The original GPU test separately contributes 12 checked dispatches from 3 modules. Counts follow the test and shared helper loops, with both adapters confirmed in the raw logs.
  • The patch also moves the existing two-line v_cmp_lg documentation, unchanged, from the scalar-pack test to v_cmp_lg_is_false_for_nan.

Negative control and final checks

A temporary IR mutation incorrectly classified the pack mnemonic stem as an SCC writer. The original GPU test still passed on hardware and WARP. The new test failed on hardware for LL, reading s15 with input [ffffffff, ffffffff, 0, 0], returning SCC 1 where the preserved value was 0. Cargo exited 101 as expected. The mutation was removed, and ir.rs and lower.rs were restored byte-for-byte before the final compilation and successful exact reruns.

  • scalar_packs_translate passed.
  • scalar_packs_take_the_halves_their_names_say passed on hardware and WARP.
  • scalar_packs_preserve_scc_with_register_and_constant_sources passed on hardware and WARP.
  • cargo clippy --release --locked -p victory-shader --all-targets -- -D warnings passed.
  • cargo run --release --locked -p xtask -- policy passed with 195 files checked.
  • Isolated new-function rustfmt --check and git diff --check passed.
  • Whole-file rustfmt still exits 1 on both pinned original and final source, with the same 17 pre-existing hunks and identical ordered added/removed formatting lines, 88 additions and 31 removals. The patch contains 76 added and 2 removed lines, consisting of the new test and the original documentation relocation.

Scope and preparation notes

The selected exact tests contain no skipped or ignored cases. The other 244 library tests filtered out by each final exact invocation were outside this targeted run. Native AMD execution, game/visual acceptance, other platforms, the full workspace suite, all source combinations and destination/source aliasing were not exercised.

An initial preparation guard incorrectly expected two existing container-hash assertions. The pinned source has two validator-load sites and one VALU hash assertion. The guard stopped before any source write or dependent test. It was corrected before the recorded acceptance runs, and that preparation attempt is excluded from the results.

Final valu_tests.rs SHA256 is e6c076bb6f1468c6e16e517a0ae30aba2ca4aab8231380b0a47171aa9a56e4ea. The patch SHA256 is f1e906166755e1df6082f92c081797e3c8b54012303bc22e7937a7349f2ca47d. Final test-executable SHA256 is 2f056bf72815b72f3befcf801b40ae62ca582a9916d5504e7e5b0c0414149a5c. Only crates/victory-shader/src/emit/valu_tests.rs differs from the pinned head.

Reproduction

Set VICTORY_STRICT_TESTS=1 and VICTORY_DXIL to the installed SDK x64 dxil.dll. After applying the patch, run the following from the repository root.

cargo test --release --locked -p victory-shader --lib emit::lower::tests::scalar_packs_translate -- --exact --nocapture --test-threads=1
cargo test --release --locked -p victory-shader --lib emit::valu_tests::scalar_packs_take_the_halves_their_names_say -- --exact --nocapture --test-threads=1
cargo test --release --locked -p victory-shader --lib emit::valu_tests::scalar_packs_preserve_scc_with_register_and_constant_sources -- --exact --nocapture --test-threads=1
Applicable regression-test patch
diff --git a/crates/victory-shader/src/emit/valu_tests.rs b/crates/victory-shader/src/emit/valu_tests.rs
index 9debe92..3eaefa7 100644
--- a/crates/victory-shader/src/emit/valu_tests.rs
+++ b/crates/victory-shader/src/emit/valu_tests.rs
@@ -537,8 +537,80 @@ fn v_med3_f16_matches_rdna2_with_nan() {
     });
 }
 
-/// `v_cmp_lg_*` is "less or greater": ordered and not equal, so false when
-/// either operand is a NaN (RDNA2 ISA; the same on gfx1036 hardware).
+#[test]
+fn scalar_packs_preserve_scc_with_register_and_constant_sources() {
+    let inputs = [
+        [0, 0],
+        [u32::MAX, u32::MAX],
+        [0x1234_5678, 0x9ABC_DEF0],
+        [0xFFFF_0000, 0x0000_FFFF],
+    ];
+    let cases: Vec<_> = [0, u32::MAX]
+        .into_iter()
+        .flat_map(|seed| inputs.map(|[a, b]| [a, b, 0, seed]))
+        .collect();
+    let constants = [[0, 0x1234_5678, 0, 0], [0, 0x1234_5678, 0, u32::MAX]];
+    for (op, name, expected, inline_want, literal_want) in [
+        (
+            0x32,
+            "s_pack_ll_b32_b16",
+            [0, u32::MAX, 0xDEF0_5678, 0xFFFF_0000],
+            0x5678_FFFF,
+            0x5678_CDEF,
+        ),
+        (
+            0x33,
+            "s_pack_lh_b32_b16",
+            [0, u32::MAX, 0x9ABC_5678, 0],
+            0x1234_FFFF,
+            0x1234_CDEF,
+        ),
+        (
+            0x34,
+            "s_pack_hh_b32_b16",
+            [0, u32::MAX, 0x9ABC_1234, 0x0000_FFFF],
+            0x1234_FFFF,
+            0x1234_89AB,
+        ),
+    ] {
+        for read in [12, 15] {
+            let shader = build_valu_cs(&[
+                sop2(0x00, 14, 3, 0x81), // incoming SCC from s3 + 1
+                sop2(op, 12, 0, 1),
+                sop2(0x0A, 15, 0x81, 0x80), // read SCC without replacing the result
+                vop1(0x001, 0, sgpr(read)),
+            ]);
+            run_cases(&shader, &cases, |backend, i, input, got| {
+                let prior = u32::from(input[3] == u32::MAX);
+                let want = if read == 15 {
+                    prior
+                } else {
+                    expected[i % inputs.len()]
+                };
+                assert_eq!(got, want, "{backend}: {name}, s{read}, input {input:x?}");
+            });
+
+            for (source, extra, value) in [
+                (0xC1, &[][..], inline_want),
+                (0xFF, &[0x89AB_CDEF][..], literal_want),
+            ] {
+                let mut body = vec![sop2(0x00, 14, 3, 0x81), sop2(op, 12, source, 1)];
+                body.extend_from_slice(extra);
+                body.extend([sop2(0x0A, 15, 0x81, 0x80), vop1(0x001, 0, sgpr(read))]);
+                let shader = build_valu_cs(&body);
+                run_cases(&shader, &constants, |backend, _, input, got| {
+                    let prior = u32::from(input[3] == u32::MAX);
+                    let want = if read == 15 { prior } else { value };
+                    assert_eq!(
+                        got, want,
+                        "{backend}: {name}, source {source:#x}, s{read}, prior SCC {prior}"
+                    );
+                });
+            }
+        }
+    }
+}
+
 #[test]
 fn scalar_packs_take_the_halves_their_names_say() {
     // s_pack_xy_b32_b16 s12, s0, s1; v_mov_b32 v0, s12.
@@ -555,6 +627,8 @@ fn scalar_packs_take_the_halves_their_names_say() {
     }
 }
 
+/// `v_cmp_lg_*` is "less or greater": ordered and not equal, so false when
+/// either operand is a NaN (RDNA2 ISA; the same on gfx1036 hardware).
 #[test]
 fn v_cmp_lg_is_false_for_nan() {
     // v_cmp_lg_{f32,f16}_e64 s20, v1, v2 (VOPC 0x005 / 0x0cd in VOP3);
<!-- greyfinch-sync:uiliannn/VItoriaBr:comment:7236886129 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/89#issuecomment-7236886129). Originally posted by [lmouz823-lang](https://github.com/lmouz823-lang) on 2026-11-28T08:54:14Z. --- ## Windows acceptance and a small regression test Tested PR #89 at `eb43d9711a91abdec336479bd6dd448b02ec25a2`, based on `2b33e081ed7831f49610b747a508fb56d3cb3aa9`. The existing scalar-pack translation and GPU tests pass. The attached test also passes and adds SCC retention, contrasting halfwords, and constant-source coverage for all three scalar packs. This is an AI-assisted contribution with local Windows execution and independent review of the fixed expected values. ### Environment and actual execution - Windows build 26200, Rust 1.98.1, NVIDIA RTX 4060 Laptop GPU with 8188 MiB and driver 610.88. - D3D12 hardware and Microsoft Basic Render Driver / WARP both executed the selected GPU tests. `VICTORY_STRICT_TESTS=1` was enabled, with an explicit Windows SDK `VICTORY_DXIL` path. Each final exact invocation ran one test and reported one pass, zero failures and zero ignored tests. No selected test was skipped. - SDK `dxil.dll` was version 1.8.2502.11 from SDK 10.0.26100.0. Its SHA256 was `77e039c905030a641e53658a008b74e90635a5ea9b6b79eabd0f2003bdfca59a`. - Temporary markers inside the existing VALU validator branch recorded successful SDK load, validation and matching DXIL container hash for 18 new-test modules and 3 original-test modules. These diagnostic runs exercised the same new test body and validator helper. The markers were removed before the final source was compiled and retested. The later final-source adjustment moved the original compare documentation to its correct test. - The final patch source was actually recompiled with `cargo test --release --locked -p victory-shader --lib --no-run`, completing in 1m10s. The two GPU exacts and the translation exact were then rerun against that final executable. ### Added coverage `scalar_packs_preserve_scc_with_register_and_constant_sources` uses fixed expected values for SOP2 0x32/0x33/0x34. The selected halves follow AMD's RDNA2 SOP2 opcodes 50–52. [AMD RDNA2 ISA](https://docs.amd.com/v/u/en-US/rdna2-shader-instruction-set-architecture) - Register pairs include zero, all ones, `12345678/9ABCDEF0`, and `FFFF0000/0000FFFF`. The distinctive pair gives LL `DEF05678`, LH `9ABC5678`, and HH `9ABC1234`. - Both incoming SCC values are established dynamically using `s_add_u32 s14, s3, 1`. The test separately reads the pack result and SCC through `s_cselect_b32 s15, 1, 0`. - Source0 additionally covers inline `-1` and a real 32-bit literal `89ABCDEF`, with source1 `12345678`, under both incoming SCC values. The expected constant results are fixed in the test. - There are 96 checked register-source dispatches and 48 constant-source dispatches across hardware and WARP, giving 144 dispatches from 18 generated modules. The original GPU test separately contributes 12 checked dispatches from 3 modules. Counts follow the test and shared helper loops, with both adapters confirmed in the raw logs. - The patch also moves the existing two-line `v_cmp_lg` documentation, unchanged, from the scalar-pack test to `v_cmp_lg_is_false_for_nan`. ### Negative control and final checks A temporary IR mutation incorrectly classified the `pack` mnemonic stem as an SCC writer. The original GPU test still passed on hardware and WARP. The new test failed on hardware for LL, reading s15 with input `[ffffffff, ffffffff, 0, 0]`, returning SCC 1 where the preserved value was 0. Cargo exited 101 as expected. The mutation was removed, and `ir.rs` and `lower.rs` were restored byte-for-byte before the final compilation and successful exact reruns. - `scalar_packs_translate` passed. - `scalar_packs_take_the_halves_their_names_say` passed on hardware and WARP. - `scalar_packs_preserve_scc_with_register_and_constant_sources` passed on hardware and WARP. - `cargo clippy --release --locked -p victory-shader --all-targets -- -D warnings` passed. - `cargo run --release --locked -p xtask -- policy` passed with 195 files checked. - Isolated new-function `rustfmt --check` and `git diff --check` passed. - Whole-file rustfmt still exits 1 on both pinned original and final source, with the same 17 pre-existing hunks and identical ordered added/removed formatting lines, 88 additions and 31 removals. The patch contains 76 added and 2 removed lines, consisting of the new test and the original documentation relocation. ### Scope and preparation notes The selected exact tests contain no skipped or ignored cases. The other 244 library tests filtered out by each final exact invocation were outside this targeted run. Native AMD execution, game/visual acceptance, other platforms, the full workspace suite, all source combinations and destination/source aliasing were not exercised. An initial preparation guard incorrectly expected two existing container-hash assertions. The pinned source has two validator-load sites and one VALU hash assertion. The guard stopped before any source write or dependent test. It was corrected before the recorded acceptance runs, and that preparation attempt is excluded from the results. Final `valu_tests.rs` SHA256 is `e6c076bb6f1468c6e16e517a0ae30aba2ca4aab8231380b0a47171aa9a56e4ea`. The patch SHA256 is `f1e906166755e1df6082f92c081797e3c8b54012303bc22e7937a7349f2ca47d`. Final test-executable SHA256 is `2f056bf72815b72f3befcf801b40ae62ca582a9916d5504e7e5b0c0414149a5c`. Only `crates/victory-shader/src/emit/valu_tests.rs` differs from the pinned head. ### Reproduction Set `VICTORY_STRICT_TESTS=1` and `VICTORY_DXIL` to the installed SDK x64 `dxil.dll`. After applying the patch, run the following from the repository root. ```powershell cargo test --release --locked -p victory-shader --lib emit::lower::tests::scalar_packs_translate -- --exact --nocapture --test-threads=1 cargo test --release --locked -p victory-shader --lib emit::valu_tests::scalar_packs_take_the_halves_their_names_say -- --exact --nocapture --test-threads=1 cargo test --release --locked -p victory-shader --lib emit::valu_tests::scalar_packs_preserve_scc_with_register_and_constant_sources -- --exact --nocapture --test-threads=1 ``` <details> <summary>Applicable regression-test patch</summary> ```diff diff --git a/crates/victory-shader/src/emit/valu_tests.rs b/crates/victory-shader/src/emit/valu_tests.rs index 9debe92..3eaefa7 100644 --- a/crates/victory-shader/src/emit/valu_tests.rs +++ b/crates/victory-shader/src/emit/valu_tests.rs @@ -537,8 +537,80 @@ fn v_med3_f16_matches_rdna2_with_nan() { }); } -/// `v_cmp_lg_*` is "less or greater": ordered and not equal, so false when -/// either operand is a NaN (RDNA2 ISA; the same on gfx1036 hardware). +#[test] +fn scalar_packs_preserve_scc_with_register_and_constant_sources() { + let inputs = [ + [0, 0], + [u32::MAX, u32::MAX], + [0x1234_5678, 0x9ABC_DEF0], + [0xFFFF_0000, 0x0000_FFFF], + ]; + let cases: Vec<_> = [0, u32::MAX] + .into_iter() + .flat_map(|seed| inputs.map(|[a, b]| [a, b, 0, seed])) + .collect(); + let constants = [[0, 0x1234_5678, 0, 0], [0, 0x1234_5678, 0, u32::MAX]]; + for (op, name, expected, inline_want, literal_want) in [ + ( + 0x32, + "s_pack_ll_b32_b16", + [0, u32::MAX, 0xDEF0_5678, 0xFFFF_0000], + 0x5678_FFFF, + 0x5678_CDEF, + ), + ( + 0x33, + "s_pack_lh_b32_b16", + [0, u32::MAX, 0x9ABC_5678, 0], + 0x1234_FFFF, + 0x1234_CDEF, + ), + ( + 0x34, + "s_pack_hh_b32_b16", + [0, u32::MAX, 0x9ABC_1234, 0x0000_FFFF], + 0x1234_FFFF, + 0x1234_89AB, + ), + ] { + for read in [12, 15] { + let shader = build_valu_cs(&[ + sop2(0x00, 14, 3, 0x81), // incoming SCC from s3 + 1 + sop2(op, 12, 0, 1), + sop2(0x0A, 15, 0x81, 0x80), // read SCC without replacing the result + vop1(0x001, 0, sgpr(read)), + ]); + run_cases(&shader, &cases, |backend, i, input, got| { + let prior = u32::from(input[3] == u32::MAX); + let want = if read == 15 { + prior + } else { + expected[i % inputs.len()] + }; + assert_eq!(got, want, "{backend}: {name}, s{read}, input {input:x?}"); + }); + + for (source, extra, value) in [ + (0xC1, &[][..], inline_want), + (0xFF, &[0x89AB_CDEF][..], literal_want), + ] { + let mut body = vec![sop2(0x00, 14, 3, 0x81), sop2(op, 12, source, 1)]; + body.extend_from_slice(extra); + body.extend([sop2(0x0A, 15, 0x81, 0x80), vop1(0x001, 0, sgpr(read))]); + let shader = build_valu_cs(&body); + run_cases(&shader, &constants, |backend, _, input, got| { + let prior = u32::from(input[3] == u32::MAX); + let want = if read == 15 { prior } else { value }; + assert_eq!( + got, want, + "{backend}: {name}, source {source:#x}, s{read}, prior SCC {prior}" + ); + }); + } + } + } +} + #[test] fn scalar_packs_take_the_halves_their_names_say() { // s_pack_xy_b32_b16 s12, s0, s1; v_mov_b32 v0, s12. @@ -555,6 +627,8 @@ fn scalar_packs_take_the_halves_their_names_say() { } } +/// `v_cmp_lg_*` is "less or greater": ordered and not equal, so false when +/// either operand is a NaN (RDNA2 ISA; the same on gfx1036 hardware). #[test] fn v_cmp_lg_is_false_for_nan() { // v_cmp_lg_{f32,f16}_e64 s20, v1, v2 (VOPC 0x005 / 0x0cd in VOP3); ``` </details>

Pull request closed

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
uiliannn/VItoriaBr!89
No description provided.