From: Jason Ekstrand Date: Wed, 12 Aug 2020 22:59:53 +0000 (-0500) Subject: nir/lower_goto_if: Replace a tripple loop with a double loop X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d2bf850672bb3691044d773c9fd96d0e80c7fcf3;p=mesa.git 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 Part-of: --- diff --git a/src/compiler/nir/nir_lower_goto_ifs.c b/src/compiler/nir/nir_lower_goto_ifs.c index dc6be58268b..e9a137d122b 100644 --- a/src/compiler/nir/nir_lower_goto_ifs.c +++ b/src/compiler/nir/nir_lower_goto_ifs.c @@ -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; - - 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; + _mesa_set_add(curr_level->blocks, candidate); + + 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; } }