[PR #448] [CLOSED] Fix for issue 331 #1570

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/448
Author: @Sailanarmo
Created: 8/16/2024
Status: Closed

Base: mainHead: patch-321


📝 Commits (8)

  • f5bb3d6 Fix for issue 331
  • 3d36d4b Update src/shader_recompiler/frontend/control_flow_graph.cpp
  • fb89776 Update src/shader_recompiler/frontend/control_flow_graph.cpp
  • 3c277f0 Merge branch 'shadps4-emu:main' into patch-321
  • 4eaa098 Update control_flow_graph.cpp
  • a374e7c Update control_flow_graph.cpp
  • 116119e Update control_flow_graph.cpp
  • 3f09e32 Update control_flow_graph.cpp

📊 Changes

1 file changed (+14 additions, -10 deletions)

View changed files

📝 src/shader_recompiler/frontend/control_flow_graph.cpp (+14 -10)

📄 Description

After studying the for loop I became aware that the loop only needed to iterate to the size of labels - 2.

This line:

  const bool is_last = next_it == labels.end();

Would check if next_it was the last position in the container and return from the function. I simplified the for loop by terminating the loop as it gets to the second to last position in the container. So the logic goes:

[1,2,3,4,5,6]
bounds = size - 2 = 4

i = 1;
i + 1 = 2;
insert[1,2];
++i;
1 < bounds true

i = 2;
i + 1 = 3;
insert[2,3];
++i;
2 < bounds true;

i = 3;
i + 1 = 4;
insert[3,4];
++i;
3 < bounds true;

i = 4;
i + 1 = 5;
insert[4,5];
++i;

4 < 4 false
terminate loop

This should eliminate the need for the check if it is the last element in the container because we are only iterating to the second to last position of the container. The only concern I have is inst_list. I did not find anywhere that makes it safe to assume that the size of labels is the same size of inst_list. I think that should have some looking into.


🔄 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/448 **Author:** [@Sailanarmo](https://github.com/Sailanarmo) **Created:** 8/16/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `patch-321` --- ### 📝 Commits (8) - [`f5bb3d6`](https://github.com/shadps4-emu/shadPS4/commit/f5bb3d65afb7bc8d69ec714a31aaa4891072c532) Fix for issue 331 - [`3d36d4b`](https://github.com/shadps4-emu/shadPS4/commit/3d36d4b317023106a6f2e554e2b5f7a8207b92aa) Update src/shader_recompiler/frontend/control_flow_graph.cpp - [`fb89776`](https://github.com/shadps4-emu/shadPS4/commit/fb89776db556083d4c14795545f6bc1414c10988) Update src/shader_recompiler/frontend/control_flow_graph.cpp - [`3c277f0`](https://github.com/shadps4-emu/shadPS4/commit/3c277f0c53bbc0d2f69d2a36b8bf09c2dedddd99) Merge branch 'shadps4-emu:main' into patch-321 - [`4eaa098`](https://github.com/shadps4-emu/shadPS4/commit/4eaa0986775b31d672ff955b5c49730c627bdc54) Update control_flow_graph.cpp - [`a374e7c`](https://github.com/shadps4-emu/shadPS4/commit/a374e7c5831312ec88a7d3d089d1a942f40e0b34) Update control_flow_graph.cpp - [`116119e`](https://github.com/shadps4-emu/shadPS4/commit/116119e8ef0c216bf4286ca2df098e9714028b90) Update control_flow_graph.cpp - [`3f09e32`](https://github.com/shadps4-emu/shadPS4/commit/3f09e3241055b9ad55cdf4bef230050a392a2838) Update control_flow_graph.cpp ### 📊 Changes **1 file changed** (+14 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/shader_recompiler/frontend/control_flow_graph.cpp` (+14 -10) </details> ### 📄 Description After studying the for loop I became aware that the loop only needed to iterate to the size of labels - 2. This line: ```cpp const bool is_last = next_it == labels.end(); ``` Would check if `next_it` was the last position in the container and return from the function. I simplified the for loop by terminating the loop as it gets to the second to last position in the container. So the logic goes: ```cpp [1,2,3,4,5,6] bounds = size - 2 = 4 i = 1; i + 1 = 2; insert[1,2]; ++i; 1 < bounds true i = 2; i + 1 = 3; insert[2,3]; ++i; 2 < bounds true; i = 3; i + 1 = 4; insert[3,4]; ++i; 3 < bounds true; i = 4; i + 1 = 5; insert[4,5]; ++i; 4 < 4 false terminate loop ``` This should eliminate the need for the check if it is the last element in the container because we are only iterating to the second to last position of the container. The only concern I have is `inst_list`. I did not find anywhere that makes it safe to assume that the size of `labels` is the same size of `inst_list`. I think that should have some looking into. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 21:13:07 +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#1570
No description provided.