[PR #1978] [MERGED] shader_recompiler: Fix BitCount64 and FindILsb64 #2416

Closed
opened 2026-02-27 21:16:25 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/1978
Author: @squidbus
Created: 12/30/2024
Status: Merged
Merged: 12/31/2024
Merged by: @georgemoralis

Base: mainHead: fix-bcnt1


📝 Commits (1)

  • 710166e shader_recompiler: Fix BitCount64 and FindILsb64

📊 Changes

2 files changed (+19 additions, -5 deletions)

View changed files

📝 src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp (+17 -2)
📝 src/shader_recompiler/frontend/translate/scalar_alu.cpp (+2 -3)

📄 Description

Vulkan places an additional restriction on a few SPIR-V bitwise instructions that they can only be used with 32-bit values. Thus, for 64-bit BitCount and FindILsb, split into 32-bit values, operate on each, and resolve the final result.

Also, I removed some extra IR logic for FindILsb, because SPIR-V already guarantees a -1 result for zero input. We can just make this part of the IR op semantics.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/1978 **Author:** [@squidbus](https://github.com/squidbus) **Created:** 12/30/2024 **Status:** ✅ Merged **Merged:** 12/31/2024 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `fix-bcnt1` --- ### 📝 Commits (1) - [`710166e`](https://github.com/shadps4-emu/shadPS4/commit/710166e746051f5b3e36a05f848db03574a5a76e) shader_recompiler: Fix BitCount64 and FindILsb64 ### 📊 Changes **2 files changed** (+19 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp` (+17 -2) 📝 `src/shader_recompiler/frontend/translate/scalar_alu.cpp` (+2 -3) </details> ### 📄 Description Vulkan places an additional restriction on a few SPIR-V bitwise instructions that they can only be used with 32-bit values. Thus, for 64-bit `BitCount` and `FindILsb`, split into 32-bit values, operate on each, and resolve the final result. Also, I removed some extra IR logic for `FindILsb`, because SPIR-V already guarantees a `-1` result for zero input. We can just make this part of the IR op semantics. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 21:16:25 +03:00
Sign in to join this conversation.
No milestone
No project
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.

Dependencies

No dependencies set.

Reference
starred/shadPS4#2416
No description provided.