summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-04-21 05:35:08 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:28 +0200
commite4d1122082e74410baac6677c850fea1a0be5c52 (patch)
treea0c8c5f4ee439dc0899e4e4f5f3356303c21809c
parentshader: Intrusively store register values in block for SSA pass (diff)
downloadyuzu-e4d1122082e74410baac6677c850fea1a0be5c52.tar
yuzu-e4d1122082e74410baac6677c850fea1a0be5c52.tar.gz
yuzu-e4d1122082e74410baac6677c850fea1a0be5c52.tar.bz2
yuzu-e4d1122082e74410baac6677c850fea1a0be5c52.tar.lz
yuzu-e4d1122082e74410baac6677c850fea1a0be5c52.tar.xz
yuzu-e4d1122082e74410baac6677c850fea1a0be5c52.tar.zst
yuzu-e4d1122082e74410baac6677c850fea1a0be5c52.zip
-rw-r--r--src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp
index e63e25aa6..6021ac891 100644
--- a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp
+++ b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp
@@ -304,6 +304,23 @@ bool SearchNode(const Tree& tree, ConstNode stmt, size_t& offset) {
return false;
}
+bool AreSiblings(Node goto_stmt, Node label_stmt) noexcept {
+ Node it{goto_stmt};
+ do {
+ if (it == label_stmt) {
+ return true;
+ }
+ --it;
+ } while (it != goto_stmt->up->children.begin());
+ while (it != goto_stmt->up->children.end()) {
+ if (it == label_stmt) {
+ return true;
+ }
+ ++it;
+ }
+ return false;
+}
+
class GotoPass {
public:
explicit GotoPass(Flow::CFG& cfg, ObjectPool<IR::Inst>& inst_pool_,
@@ -353,22 +370,10 @@ private:
}
}
}
- // TODO: Remove this
- {
- Node it{goto_stmt};
- bool sibling{false};
- do {
- sibling |= it == label_stmt;
- --it;
- } while (it != goto_stmt->up->children.begin());
- while (it != goto_stmt->up->children.end()) {
- sibling |= it == label_stmt;
- ++it;
- }
- if (!sibling) {
- throw LogicError("Not siblings");
- }
- }
+ // Expensive operation:
+ // if (!AreSiblings(goto_stmt, label_stmt)) {
+ // throw LogicError("Goto is not a sibling with the label");
+ // }
// goto_stmt and label_stmt are guaranteed to be siblings, eliminate
if (std::next(goto_stmt) == label_stmt) {
// Simply eliminate the goto if the label is next to it