[PR #3296] [MERGED] control_flow_graph: Treat empty conditional branch as noop #3366

Closed
opened 2026-02-27 22:03:26 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3296
Author: @raphaelthegreat
Created: 7/22/2025
Status: Merged
Merged: 7/23/2025
Merged by: @georgemoralis

Base: mainHead: empty-branch


📝 Commits (1)

  • 68703bd control_flow_graph: Treat empty conditional branch as noop

📊 Changes

1 file changed (+4 additions, -2 deletions)

View changed files

📝 src/shader_recompiler/frontend/control_flow_graph.cpp (+4 -2)

📄 Description

This fixes the motion blur in Driveclub (CUSA00093)

In the offending shader the AMD compiler appears to have had a derp moment and emitted an empty branch. It wants to check if s28 <= v5, but instead of doing it directly, it checks s28 > v5, does an empty branch, reverses the condition and then does the actual branch. This confuses the structurization passes (not exactly sure yet though) and causes the branch to be s28 > v5. Avoid this by not ending a block on such no-op branches, so the reversing of condition is also part of the branch

v_cmp_gt_f32    vcc, s28, v5
s_and_saveexec_b64 s[24:25], vcc
s_cbranch_execz .L596_0
.L596_0:
s_andn2_b64     exec, s[24:25], exec
s_cbranch_execz .L1048_0

🔄 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/3296 **Author:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Created:** 7/22/2025 **Status:** ✅ Merged **Merged:** 7/23/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `empty-branch` --- ### 📝 Commits (1) - [`68703bd`](https://github.com/shadps4-emu/shadPS4/commit/68703bddcb3f09b1a026a321cfa3da81ed3ed652) control_flow_graph: Treat empty conditional branch as noop ### 📊 Changes **1 file changed** (+4 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/shader_recompiler/frontend/control_flow_graph.cpp` (+4 -2) </details> ### 📄 Description This fixes the motion blur in Driveclub (CUSA00093) In the offending shader the AMD compiler appears to have had a derp moment and emitted an empty branch. It wants to check if s28 <= v5, but instead of doing it directly, it checks s28 > v5, does an empty branch, reverses the condition and then does the actual branch. This confuses the structurization passes (not exactly sure yet though) and causes the branch to be s28 > v5. Avoid this by not ending a block on such no-op branches, so the reversing of condition is also part of the branch ``` v_cmp_gt_f32 vcc, s28, v5 s_and_saveexec_b64 s[24:25], vcc s_cbranch_execz .L596_0 .L596_0: s_andn2_b64 exec, s[24:25], exec s_cbranch_execz .L1048_0 ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:03:26 +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#3366
No description provided.