Mesa (master): nir/lower_goto_if: Replace a tripple loop with a double loop
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Aug 14 20:55:37 UTC 2020
Module: Mesa
Branch: master
Commit: d2bf850672bb3691044d773c9fd96d0e80c7fcf3
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d2bf850672bb3691044d773c9fd96d0e80c7fcf3
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Wed Aug 12 17:59:53 2020 -0500
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 at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401>
---
src/compiler/nir/nir_lower_goto_ifs.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
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;
}
}
More information about the mesa-commit
mailing list