Mesa (master): nir/lower_goto_if: Rework some set union logic

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 14 20:55:37 UTC 2020


Module: Mesa
Branch: master
Commit: 0fad20f21b39b72c965151a0e2b0fb36e436b813
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0fad20f21b39b72c965151a0e2b0fb36e436b813

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Wed Aug 12 15:47:18 2020 -0500

nir/lower_goto_if: Rework some set union logic

I find the ternary a bit hard to read.  The optimization is fairly
obvious but the way it's coded makes things more dense than they
probably need to be.

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 | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/compiler/nir/nir_lower_goto_ifs.c b/src/compiler/nir/nir_lower_goto_ifs.c
index b944b4c3164..ac202950fb6 100644
--- a/src/compiler/nir/nir_lower_goto_ifs.c
+++ b/src/compiler/nir/nir_lower_goto_ifs.c
@@ -612,9 +612,16 @@ organize_levels(struct list_head *levels, struct set *remaining,
       } else {
          set_foreach(curr_level->blocks, blocks_entry) {
             nir_block *level_block = (nir_block *) blocks_entry->key;
-            if (!prev_frontier) {
-               prev_frontier = curr_level->blocks->entries == 1 ?
-                  level_block->dom_frontier :
+            if (curr_level->blocks->entries == 1) {
+               /* If we only have one block, there's no union operation and we
+                * can just use the one from the one block.
+                */
+               prev_frontier = level_block->dom_frontier;
+               break;
+            }
+
+            if (prev_frontier == NULL) {
+               prev_frontier =
                   _mesa_set_clone(level_block->dom_frontier, prev_level);
             } else {
                set_foreach(level_block->dom_frontier, entry)



More information about the mesa-commit mailing list