shader: read float inline constants on 64-bit operands as f64 bits #1576

Manually merged
github merged 1 commit from gh-pr/1576/head into gh-pr/1576/base 2026-11-26 10:00:11 +00:00
Owner

@⁠Nawid3333 on GitHub · 2026-10-17 00:18 UTC · original
Nawid3333:shader/inline-float-constants-64bit → main · +37 −7 · 2 files · 1 commits · merged 2026-10-17 03:21 UTC

A float inline constant (0.5, 1.0, 2.0, 4.0, their negatives, 1/(2π)) read by a 64-bit operand is the f64 bit pattern, for integer B64 opcodes as well as F64 ones. ReadU32Pair returned {f32 bits, 0}, so only F64-typed reads had the right value. s_mov_b64 s[0:1], 1.0 gave 0x3f800000 instead of 0x3ff0000000000000, and so did the 64-bit SALU logic ops, S_CSELECT_B64, S_CMP_*_U64, V_LSHRREV_B64 and V_CMP_*_U64 with such a constant.

Evidence:

  • The RDNA2 guide only spells out 32-bit literals here.
  • LLVM's AMDGPU disassembler decodes inline constants on INT64 operands with getInlineImmVal64 (242 is bit_cast<uint64_t>(1.0)).
  • On both GPUs here, AMD's driver uses these constants on 64-bit integer operands. 0x3fe0000000000000ul >> lane becomes v_lshrrev_b64 v[n:n+1], v0, 0.5, and likewise for 1.0, 2.0, -4.0 and 1/(2π) (0x3fc45f306dc9c882). The shifted results read back right. A 64-bit compare with 0x3ff0000000000000 uses 1.0 too (v_cmp_eq_u64 on the RX 9070 XT, v_cmp_eq_i64 on the iGPU).

Change: the f64 conversion moves from the F64 path of ReadOperand into ReadU32Pair, so every 64-bit read through it gets it.

Test: ScalarVector64BitFloatInlineConstants:

  • s_mov_b64 of 1.0 and of 1/(2π);
  • s_or_b64 with 0.5;
  • v_lshrrev_b64 of 2.0;
  • s_cmp_eq_u64 of a register holding 0x3ff0000000000000 against 1.0.

Before the change it fails on both GPUs (f32 bits); after it passes, also with 32-wide subgroups.

  • On both GPUs, every compute-suite entry, also with 32-wide subgroups, gives the same status and first mismatch as without the change, except the new test. The graphics cases are unchanged too.
  • Fork CI (build and tests on Windows, Linux and macOS) passes.

Based on TheCruZ's 284deab28 (#1219, closed on 10-10). This version leaves ReadMask reading through ReadU32Pair, so B64 mask instructions get the 64-bit value in wave32 too. (VALU lane-mask operands such as v_cndmask's take registers only in LLVM, SSrc_i1.)

If you'd like this done differently, tell me and I'll change it.

Written with Claude Code (AI): it wrote the change and the test and ran them on my PC (driver 26.8.1, Windows 11). I reviewed the diff and this description before opening the PR.

🤖 Generated with Claude Code

**@⁠Nawid3333** on GitHub · 2026-10-17 00:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1576) `Nawid3333:shader/inline-float-constants-64bit` → `main` · +37 −7 · 2 files · 1 commits · merged 2026-10-17 03:21 UTC A float inline constant (0.5, 1.0, 2.0, 4.0, their negatives, 1/(2π)) read by a 64-bit operand is the f64 bit pattern, for integer B64 opcodes as well as F64 ones. `ReadU32Pair` returned `{f32 bits, 0}`, so only F64-typed reads had the right value. `s_mov_b64 s[0:1], 1.0` gave 0x3f800000 instead of 0x3ff0000000000000, and so did the 64-bit SALU logic ops, `S_CSELECT_B64`, `S_CMP_*_U64`, `V_LSHRREV_B64` and `V_CMP_*_U64` with such a constant. Evidence: - The RDNA2 guide only spells out 32-bit literals here. - LLVM's AMDGPU disassembler decodes inline constants on `INT64` operands with `getInlineImmVal64` (242 is `bit_cast<uint64_t>(1.0)`). - On both GPUs here, AMD's driver uses these constants on 64-bit integer operands. `0x3fe0000000000000ul >> lane` becomes `v_lshrrev_b64 v[n:n+1], v0, 0.5`, and likewise for 1.0, 2.0, -4.0 and 1/(2π) (0x3fc45f306dc9c882). The shifted results read back right. A 64-bit compare with 0x3ff0000000000000 uses 1.0 too (`v_cmp_eq_u64` on the RX 9070 XT, `v_cmp_eq_i64` on the iGPU). **Change:** the f64 conversion moves from the F64 path of `ReadOperand` into `ReadU32Pair`, so every 64-bit read through it gets it. **Test:** `ScalarVector64BitFloatInlineConstants`: - `s_mov_b64` of 1.0 and of 1/(2π); - `s_or_b64` with 0.5; - `v_lshrrev_b64` of 2.0; - `s_cmp_eq_u64` of a register holding 0x3ff0000000000000 against 1.0. Before the change it fails on both GPUs (f32 bits); after it passes, also with 32-wide subgroups. - On both GPUs, every compute-suite entry, also with 32-wide subgroups, gives the same status and first mismatch as without the change, except the new test. The graphics cases are unchanged too. - Fork CI (build and tests on Windows, Linux and macOS) passes. Based on TheCruZ's 284deab28 (#1219, closed on 10-10). This version leaves `ReadMask` reading through `ReadU32Pair`, so B64 mask instructions get the 64-bit value in wave32 too. (VALU lane-mask operands such as `v_cndmask`'s take registers only in LLVM, `SSrc_i1`.) If you'd like this done differently, tell me and I'll change it. Written with Claude Code (AI): it wrote the change and the test and ran them on my PC (driver 26.8.1, Windows 11). I reviewed the diff and this description before opening the PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A float inline constant (240-248) read by a 64-bit operand is the f64 bit
pattern for integer B64 opcodes too: AMD's compilers emit
v_lshrrev_b64 v[4:5], v0, 1.0 for 0x3ff0000000000000 >> lane. ReadU32Pair
returned {f32 bits, 0}, so only F64-typed reads had the right value.

Based on TheCruZ's 284deab28 (closed #1219).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:00:09 +00:00
github manually merged commit 148e8b6fae into gh-pr/1576/base 2026-11-26 10:00:11 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 00:24 UTC · original

Review in Change Stack →

📝 Walkthrough

Float inline constant conversion now occurs in ReadU32Pair, which returns the low and high words of the F64 value. The existing explicit F64 bit pattern for 0x3e22f983 remains. A registered compute test covers inline constants in scalar and vector 64-bit operations.

Suggested reviewers: nmzik, thecruz

Priority: ➖ Normal

Change: Bug fix

Merge Risk: 🔵 Low · up to 148e8

Float-inline constants used as masks can select the wrong lanes. Preserve their raw bits in the mask path before merging.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the 64-bit float inline constant bug, the implementation change, the added test, and reported validation results.
Title check Passed The title clearly and concisely identifies the main change: reading float inline constants as f64 bit patterns for 64-bit operands.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. (1 skipped: 1 too large.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 00:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1576#issuecomment-6227299285) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1576?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> Float inline constant conversion now occurs in `ReadU32Pair`, which returns the low and high words of the F64 value. The existing explicit F64 bit pattern for `0x3e22f983` remains. A registered compute test covers inline constants in scalar and vector 64-bit operations. **Suggested reviewers:** `nmzik`, `thecruz` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"148e8b6faec1f58284ee939f75a189b715309e57" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🔵 Low</strong> · up to <code>148e8</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `148e8` --> <!-- final_review_risk_coverage:{"sourceCommitId":"148e8b6faec1f58284ee939f75a189b715309e57","coveredCommitId":"148e8b6faec1f58284ee939f75a189b715309e57","kind":"reviewed"} --> Float-inline constants used as masks can select the wrong lanes. Preserve their raw bits in the mask path before merging. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-inconclusive-14-v2.svg" width="14" height="14" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 inconclusive</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. (1 skipped: 1 … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------- | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description clearly explains the 64-bit float inline constant bug, the implementation change, the added test, and reported validation results. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely identifies the main change: reading float inline constants as f64 bit patterns for 64-bit operands. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. (1 skipped: 1 too large.) **Resolution** Write docstrings for the functions missing them to satisfy the coverage threshold. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1576)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -491,0 +488,4 @@
: std::bit_cast<uint64_t>(static_cast<double>(std::bit_cast<float>(operand.value)));
return {IR::U32(IR::Value(static_cast<uint32_t>(bits))),
IR::U32(IR::Value(static_cast<uint32_t>(bits >> 32u)))};
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 00:24 UTC · original · edited 2026-10-17 00:45 UTC

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '605,660p' src/graphics/shader/recompiler/frontend/translate/Translate.cpp
rg -n 'ThreadBit\(|S_U64_MASK|V_CNDMASK_B32' src/graphics/shader/recompiler/frontend/translate tests/ShaderRecompilerComputeTests.cpp | head -85

Repository: KytyPS5/KytyPS5

Length of output: 9955


🏁 Script executed:

set -eu
printf '%s\n' '--- current ReadU32Pair and ReadMask ---'
sed -n '455,505p;600,660p' src/graphics/shader/recompiler/frontend/translate/Translate.cpp
printf '%s\n' '--- V_CNDMASK_B32 and S_U64_MASK ---'
sed -n '80,110p;520,545p' src/graphics/shader/recompiler/frontend/translate/Integer.cpp
printf '%s\n' '--- decoder float inline constants ---'
sed -n '220,270p' src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cpp
printf '%s\n' '--- changed diff against merge base ---'
git diff --unified=12 42bb0da520992e35f062f44e6762484c356b9ded 148e8b6faec1f58284ee939f75a189b715309e57 -- src/graphics/shader/recompiler/frontend/translate/Translate.cpp tests/ShaderRecompilerComputeTests.cpp
printf '%s\n' '--- nearby predicate-oriented tests ---'
rg -n -C 8 -F -- 'V_CNDMASK_B32 v' tests/ShaderRecompilerComputeTests.cpp | rg -n -C 3 '0xf|0x3f|S_MOV_B32|S_MOV_B64|FloatInline|V_CNDMASK' | head -160 || true

Repository: KytyPS5/KytyPS5

Length of output: 16733


Use the raw f32 pair for float-inline masks.

ReadMask passes float-inline constants to ThreadBit through the new f64 projection. For 0.5f (0x3f000000), lane 24 reads 1 from the raw f32 word but 0 from the converted pair {0, 0x3fe00000} in a wave32. V_CNDMASK_B32 and S_U64_MASK can therefore produce different per-lane results.

Keep the f64 projection in ReadU32Pair for 64-bit data operands. Use the raw f32 word when ReadMask handles a float-inline constant.

Suggested fix
 	if (operand.kind == Decoder::OperandKind::LiteralConstant ||
 	    operand.kind == Decoder::OperandKind::IntegerInlineConstant ||
 	    operand.kind == Decoder::OperandKind::FloatInlineConstant) {
-		return ThreadBit(ReadU32Pair(operand));
+		const auto mask = operand.kind == Decoder::OperandKind::FloatInlineConstant
+		                      ? std::array {ReadRawU32(operand), IR::U32(IR::Value(0u))}
+		                      : ReadU32Pair(operand);
+		return ThreadBit(mask);
 	}
**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 00:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1576#discussion_r4300472923) · edited 2026-10-17 00:45 UTC **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '605,660p' src/graphics/shader/recompiler/frontend/translate/Translate.cpp rg -n 'ThreadBit\(|S_U64_MASK|V_CNDMASK_B32' src/graphics/shader/recompiler/frontend/translate tests/ShaderRecompilerComputeTests.cpp | head -85 ``` Repository: KytyPS5/KytyPS5 Length of output: 9955 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- current ReadU32Pair and ReadMask ---' sed -n '455,505p;600,660p' src/graphics/shader/recompiler/frontend/translate/Translate.cpp printf '%s\n' '--- V_CNDMASK_B32 and S_U64_MASK ---' sed -n '80,110p;520,545p' src/graphics/shader/recompiler/frontend/translate/Integer.cpp printf '%s\n' '--- decoder float inline constants ---' sed -n '220,270p' src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cpp printf '%s\n' '--- changed diff against merge base ---' git diff --unified=12 42bb0da520992e35f062f44e6762484c356b9ded 148e8b6faec1f58284ee939f75a189b715309e57 -- src/graphics/shader/recompiler/frontend/translate/Translate.cpp tests/ShaderRecompilerComputeTests.cpp printf '%s\n' '--- nearby predicate-oriented tests ---' rg -n -C 8 -F -- 'V_CNDMASK_B32 v' tests/ShaderRecompilerComputeTests.cpp | rg -n -C 3 '0xf|0x3f|S_MOV_B32|S_MOV_B64|FloatInline|V_CNDMASK' | head -160 || true ``` Repository: KytyPS5/KytyPS5 Length of output: 16733 --- </details> **Use the raw f32 pair for float-inline masks.** `ReadMask` passes float-inline constants to `ThreadBit` through the new f64 projection. For `0.5f` (`0x3f000000`), lane 24 reads `1` from the raw f32 word but `0` from the converted pair `{0, 0x3fe00000}` in a wave32. `V_CNDMASK_B32` and `S_U64_MASK` can therefore produce different per-lane results. Keep the f64 projection in `ReadU32Pair` for 64-bit data operands. Use the raw f32 word when `ReadMask` handles a float-inline constant. <details><summary>Suggested fix</summary> ```diff if (operand.kind == Decoder::OperandKind::LiteralConstant || operand.kind == Decoder::OperandKind::IntegerInlineConstant || operand.kind == Decoder::OperandKind::FloatInlineConstant) { - return ThreadBit(ReadU32Pair(operand)); + const auto mask = operand.kind == Decoder::OperandKind::FloatInlineConstant + ? std::array {ReadRawU32(operand), IR::U32(IR::Value(0u))} + : ReadU32Pair(operand); + return ThreadBit(mask); } ``` </details> <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:cec77f6ef4b56a0e3f1e787b --> <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 00:24 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f235f97a-5c44-4c92-b9bf-f4520cb8dd75
📥 Commits

Reviewing files that changed from the base of the PR and between 42bb0da520 and 148e8b6fae.

📒 Files selected for processing: 2
  • src/graphics/shader/recompiler/frontend/translate/Translate.cpp
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 00:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1576#pullrequestreview-5555051790) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `f235f97a-5c44-4c92-b9bf-f4520cb8dd75` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 42bb0da520992e35f062f44e6762484c356b9ded and 148e8b6faec1f58284ee939f75a189b715309e57. </details> <details> <summary>📒 Files selected for processing: 2</summary> * `src/graphics/shader/recompiler/frontend/translate/Translate.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=14319df3-450d-497f-baa0-afea9f289eb1 attempt=b3e2bca2-475f-43bf-8ace-fb59945b45b0 batch=1/1 -->
@ -491,0 +488,4 @@
: std::bit_cast<uint64_t>(static_cast<double>(std::bit_cast<float>(operand.value)));
return {IR::U32(IR::Value(static_cast<uint32_t>(bits))),
IR::U32(IR::Value(static_cast<uint32_t>(bits >> 32u)))};
}
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-17 00:45 UTC · original

I'll keep ReadMask on ReadU32Pair. The instructions that read a constant through ReadMask are 64-bit SALU ops (S_U64_MASK, S_CSELECT_B64, the 64-bit S_*_SAVEEXEC), so the constant is a 64-bit operand and the hardware reads its f64 pattern. With an EXEC or VCC operand, S_U64_MASK also computes the scalar it writes from this per-lane mask (WriteMask(inst.dst, invocation_result, true)). With the raw f32 word, s_and_b64 exec, exec, 0.5 would give EXEC the f32 pattern. Without EXEC/VCC, the scalar comes from ReadU32Pair and only the mask provenance from ReadMask, and the two would disagree.

The VALU lane-mask operands (v_cndmask_b32's mask, the carry-in) are SGPRs: the RDNA2 guide says "In VOP3 the VCC source may be a scalar GPR specified in S2", and LLVM's operand for them (SSrc_i1, decodeBoolReg) takes registers only. So a float inline constant doesn't occur there.

**@⁠Nawid3333** on GitHub · 2026-10-17 00:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1576#discussion_r4300554018) I'll keep `ReadMask` on `ReadU32Pair`. The instructions that read a constant through `ReadMask` are 64-bit SALU ops (`S_U64_MASK`, `S_CSELECT_B64`, the 64-bit `S_*_SAVEEXEC`), so the constant is a 64-bit operand and the hardware reads its f64 pattern. With an EXEC or VCC operand, `S_U64_MASK` also computes the scalar it writes from this per-lane mask (`WriteMask(inst.dst, invocation_result, true)`). With the raw f32 word, `s_and_b64 exec, exec, 0.5` would give EXEC the f32 pattern. Without EXEC/VCC, the scalar comes from `ReadU32Pair` and only the mask provenance from `ReadMask`, and the two would disagree. The VALU lane-mask operands (`v_cndmask_b32`'s mask, the carry-in) are SGPRs: the RDNA2 guide says "In VOP3 the VCC source may be a scalar GPR specified in S2", and LLVM's operand for them (`SSrc_i1`, `decodeBoolReg`) takes registers only. So a float inline constant doesn't occur there.
@ -491,0 +488,4 @@
: std::bit_cast<uint64_t>(static_cast<double>(std::bit_cast<float>(operand.value)));
return {IR::U32(IR::Value(static_cast<uint32_t>(bits))),
IR::U32(IR::Value(static_cast<uint32_t>(bits >> 32u)))};
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 00:46 UTC · original

@⁠Nawid3333 You're right. I withdraw this finding.

ReadMask must use the same 64-bit pattern as ReadU32Pair for these SALU constant operands. My raw-f32 exception would make the scalar value and its per-lane mask disagree. My V_CNDMASK_B32 example also assumed a float-inline mask source that its register-only operand does not permit.

Thanks for the clarification. No change is needed here.


✏️ Learnings added
Learnt from: Nawid3333
Repo: KytyPS5/KytyPS5 PR: 1576
File: src/graphics/shader/recompiler/frontend/translate/Translate.cpp:484-491
Timestamp: 2026-10-17T00:46:14.076Z
Learning: In KytyPS5/KytyPS5's C++ shader translator, src/graphics/shader/recompiler/frontend/translate/Translate.cpp, keep ReadMask constant handling consistent with ReadU32Pair. Constant sources used by S_U64_MASK, S_CSELECT_B64, and 64-bit S_*_SAVEEXEC are 64-bit operands, so float inline constants use their f64 bit patterns. A raw-f32 exception would make scalar values and mask provenance disagree, including EXEC/VCC results written through WriteMask. VALU lane-mask sources, such as V_CNDMASK_B32's mask and carry-in operands, are register-only operands (LLVM SSrc_i1/decodeBoolReg), so float-inline mask examples do not apply to them.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 00:46 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1576#discussion_r4300555646) @⁠Nawid3333 You're right. I withdraw this finding. `ReadMask` must use the same 64-bit pattern as `ReadU32Pair` for these SALU constant operands. My raw-f32 exception would make the scalar value and its per-lane mask disagree. My `V_CNDMASK_B32` example also assumed a float-inline mask source that its register-only operand does not permit. Thanks for the clarification. No change is needed here. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: Nawid3333 Repo: KytyPS5/KytyPS5 PR: 1576 File: src/graphics/shader/recompiler/frontend/translate/Translate.cpp:484-491 Timestamp: 2026-10-17T00:46:14.076Z Learning: In KytyPS5/KytyPS5's C++ shader translator, src/graphics/shader/recompiler/frontend/translate/Translate.cpp, keep ReadMask constant handling consistent with ReadU32Pair. Constant sources used by S_U64_MASK, S_CSELECT_B64, and 64-bit S_*_SAVEEXEC are 64-bit operands, so float inline constants use their f64 bit patterns. A raw-f32 exception would make scalar values and mask provenance disagree, including EXEC/VCC results written through WriteMask. VALU lane-mask sources, such as V_CNDMASK_B32's mask and carry-in operands, are register-only operands (LLVM SSrc_i1/decodeBoolReg), so float-inline mask examples do not apply to them. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> <!-- <review_comment_withdrawn> --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.