nir/lower_goto_if: Replace a tripple loop with a double loop

If there's some reason why this needs to be a tripple loop, I'm not
seeing it.  As far as I can tell, all the inner-most loop does is look
for the next remaining block not already in cur_level->blocks.  There's
no reason to re-walk the whole set every time just to do that.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401>
This commit is contained in:
Jason Ekstrand
2020-08-12 17:59:53 -05:00
committed by Marge Bot
parent b892d473b4
commit d2bf850672

View File

@@ -531,23 +531,21 @@ handle_irreducible(struct set *remaining, struct strct_lvl *curr_level,
struct set *old_candidates = _mesa_pointer_set_create(mem_ctx);
while (candidate) {
_mesa_set_add(old_candidates, candidate);
nir_block *to_be_added = candidate;
candidate = NULL;
/* Start with just the candidate block */
_mesa_set_clear(curr_level->blocks, NULL);
while (to_be_added) {
_mesa_set_add(curr_level->blocks, to_be_added);
to_be_added = NULL;
_mesa_set_add(curr_level->blocks, candidate);
set_foreach(remaining, entry) {
nir_block *remaining_block = (nir_block *) entry->key;
if (!_mesa_set_search(curr_level->blocks, remaining_block)
&& _mesa_set_intersects(remaining_block->dom_frontier,
curr_level->blocks)) {
if (_mesa_set_search(old_candidates, remaining_block))
to_be_added = remaining_block;
else
candidate = remaining_block;
candidate = NULL;
set_foreach(remaining, entry) {
nir_block *remaining_block = (nir_block *) entry->key;
if (!_mesa_set_search(curr_level->blocks, remaining_block) &&
_mesa_set_intersects(remaining_block->dom_frontier,
curr_level->blocks)) {
if (_mesa_set_search(old_candidates, remaining_block)) {
_mesa_set_add(curr_level->blocks, remaining_block);
} else {
candidate = remaining_block;
break;
}
}