nir/from_ssa: Make additional assumptions in coalescing
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Wed, 31 May 2023 18:55:47 +0000 (13:55 -0500)
committerMarge Bot <emma+marge@anholt.net>
Wed, 12 Jul 2023 01:34:27 +0000 (01:34 +0000)
At this point, everything is SSA.  Also, NIR no longer allows different
numbers of components on the two sides of a phi so we can just assert
rather than trying to gracefully handle mismatches.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23089>

src/compiler/nir/nir_from_ssa.c

index 5d216ca..9375802 100644 (file)
@@ -457,8 +457,9 @@ aggressive_coalesce_parallel_copy(nir_parallel_copy_instr *pcopy,
                                  struct from_ssa_state *state)
 {
    nir_foreach_parallel_copy_entry(entry, pcopy) {
-      if (!entry->src.is_ssa)
-         continue;
+      assert(entry->src.is_ssa);
+      assert(entry->dest.is_ssa);
+      assert(entry->dest.ssa.num_components == entry->src.ssa->num_components);
 
       /* Since load_const instructions are SSA only, we can't replace their
        * destinations with registers and, therefore, can't coalesce them.
@@ -466,10 +467,6 @@ aggressive_coalesce_parallel_copy(nir_parallel_copy_instr *pcopy,
       if (entry->src.ssa->parent_instr->type == nir_instr_type_load_const)
          continue;
 
-      /* Don't try and coalesce these */
-      if (entry->dest.ssa.num_components != entry->src.ssa->num_components)
-         continue;
-
       merge_node *src_node = get_merge_node(entry->src.ssa, state);
       merge_node *dest_node = get_merge_node(&entry->dest.ssa, state);