mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-12-21 10:17:38 +00:00
shader: Move siblings check to a separate function and comment them out
This commit is contained in:
parent
4209828646
commit
e4d1122082
|
@ -304,6 +304,23 @@ bool SearchNode(const Tree& tree, ConstNode stmt, size_t& offset) {
|
||||||
return false;
|
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 {
|
class GotoPass {
|
||||||
public:
|
public:
|
||||||
explicit GotoPass(Flow::CFG& cfg, ObjectPool<IR::Inst>& inst_pool_,
|
explicit GotoPass(Flow::CFG& cfg, ObjectPool<IR::Inst>& inst_pool_,
|
||||||
|
@ -353,22 +370,10 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Remove this
|
// Expensive operation:
|
||||||
{
|
// if (!AreSiblings(goto_stmt, label_stmt)) {
|
||||||
Node it{goto_stmt};
|
// throw LogicError("Goto is not a sibling with the label");
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// goto_stmt and label_stmt are guaranteed to be siblings, eliminate
|
// goto_stmt and label_stmt are guaranteed to be siblings, eliminate
|
||||||
if (std::next(goto_stmt) == label_stmt) {
|
if (std::next(goto_stmt) == label_stmt) {
|
||||||
// Simply eliminate the goto if the label is next to it
|
// Simply eliminate the goto if the label is next to it
|
||||||
|
|
Loading…
Reference in a new issue