nir/lower_goto_if: Add a block_for_singular_set helper
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 12 Aug 2020 22:10:49 +0000 (17:10 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 14 Aug 2020 20:35:37 +0000 (20:35 +0000)
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401>

src/compiler/nir/nir_lower_goto_ifs.c

index 2d7e4946c88ffb606797888d8ae363642c28ebd3..dc6be58268b5c417416858e549fb30c281926632 100644 (file)
@@ -105,6 +105,13 @@ sorted_block_arr_for_set(const struct set *block_set, void *mem_ctx)
    return block_arr;
 }
 
+static nir_block *
+block_for_singular_set(const struct set *block_set)
+{
+   assert(block_set->entries == 1);
+   return (nir_block *)_mesa_set_next_entry(block_set, NULL)->key;
+}
+
 /**
  * Sets all path variables to reach the target block via a fork
  */
@@ -734,9 +741,8 @@ select_blocks(struct routes *routing, nir_builder *b,
               struct path in_path, void *mem_ctx)
 {
    if (!in_path.fork) {
-      nir_structurize(routing, b, (nir_block *)
-                      _mesa_set_next_entry(in_path.reachable, NULL)->key,
-                      mem_ctx);
+      nir_block *block = block_for_singular_set(in_path.reachable);
+      nir_structurize(routing, b, block, mem_ctx);
    } else {
       assert(!(in_path.fork->is_var &&
                strcmp(in_path.fork->path_var->name, "path_select")));