Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commented out potential path for continue_block_can_merge. #98

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions cfg_structurizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,49 @@ bool CFGStructurizer::continue_block_can_merge(CFGNode *node) const
// we see in the wild. It's probably safe to block continue merge in far more cases than this, but we
// want to be maximally convergent as often as we can.

#if 0
// This path breaks many shaders, but keep it as a reference for potential future fixes ...
bool continue_block_is_control_dependent = block_is_control_dependent(node);

if (!continue_block_is_control_dependent && node->pred.size() >= 3 &&
block_is_plain_continue(node) && node->post_dominates(header))
{
// If we have more than 2 preds and we're not control dependent,
// we should probably treat this as an unmerged continue block.

// Try to find any proof of an entry-exit relationship inside the loop where the continue is the exit.
UnorderedSet<const CFGNode *> traversed;
bool has_inner_loop_construct = false;
bool has_candidate = false;

header->traverse_dominated_blocks([&](const CFGNode *candidate) -> bool {
if (candidate == node)
return false;
if (traversed.count(candidate))
return false;
traversed.insert(candidate);

if (candidate != header && candidate->pred_back_edge)
{
auto *post_dominator = find_common_post_dominator(candidate->succ);
if (post_dominator == node)
has_inner_loop_construct = true;
}

if (candidate->num_forward_preds() >= 2 && !candidate->dominates(node) &&
candidate->immediate_dominator != header &&
candidate->immediate_dominator->immediate_post_dominator == node)
{
has_candidate = true;
}

return true;
});

return !has_candidate || has_inner_loop_construct;
}
#endif

for (auto *pred : node->pred)
{
// If we have a situation where a continue block has a pred which is itself a selection merge target, that
Expand Down