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>
diff --git a/src/compiler/nir/nir_lower_goto_ifs.c b/src/compiler/nir/nir_lower_goto_ifs.c
index dc6be58..e9a137d 100644
--- a/src/compiler/nir/nir_lower_goto_ifs.c
+++ b/src/compiler/nir/nir_lower_goto_ifs.c
@@ -531,23 +531,21 @@
    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;
             }
          }