shader: stop repeated CFG merge gateway splitting

This commit is contained in:
nmzik
2026-09-25 13:44:07 +04:00
parent 93185953f1
commit 6bb68a3fd9
2 changed files with 48 additions and 0 deletions
@@ -1389,6 +1389,15 @@ bool SplitSharedMergeBlock(Graph& graph, uint32_t merge,
if (construct_predecessors.empty() || (!force_split && !has_external_predecessor)) {
return false;
}
if (construct_predecessors.size() == 1u) {
const auto* predecessor = graph.FindBlock(construct_predecessors.front());
if (predecessor != nullptr && predecessor->inst_begin == predecessor->inst_end &&
predecessor->terminator.kind == TerminatorKind::Branch &&
predecessor->terminator.true_block == merge &&
predecessor->start_pc == merge_block->start_pc) {
return false;
}
}
const auto synthetic_merge = AppendSyntheticBranchBlock(graph, merge);
auto* synthetic_block = graph.FindBlock(synthetic_merge);
if (synthetic_block != nullptr) {