pan/bi: Don't remove dests in DCE
authorAlyssa Rosenzweig <alyssa@collabora.com>
Thu, 21 Jul 2022 19:40:05 +0000 (15:40 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 2 Sep 2022 16:03:23 +0000 (16:03 +0000)
Removing dests without removing instructions only makes sense for certain
pseudo-instructions, but it makes the IR needlessly complicated for all
instructions. There's no real reason to do so, we can signal this in a different
way instead.

No shader-db changes.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17794>

src/panfrost/bifrost/bi_opt_dce.c
src/panfrost/bifrost/bi_ra.c

index 24c43ca..84ea988 100644 (file)
@@ -46,8 +46,6 @@ bi_opt_dead_code_eliminate(bi_context *ctx)
                         bool all_null = true;
 
                         bi_foreach_dest(ins, d) {
-                                unsigned index = bi_get_node(ins->dest[d]);
-
                                 /* Destination required */
                                 if (ins->op == BI_OPCODE_AXCHG_I32 ||
                                     ins->op == BI_OPCODE_ACMPXCHG_I32 ||
@@ -58,10 +56,12 @@ bi_opt_dead_code_eliminate(bi_context *ctx)
                                     ins->op == BI_OPCODE_ZS_EMIT)
                                         continue;
 
-                                if (index < temp_count && !(live[index] & bi_writemask(ins, d)))
-                                        ins->dest[d] = bi_null();
+                                unsigned index = bi_get_node(ins->dest[d]);
 
-                                all_null &= bi_is_null(ins->dest[d]);
+                                if (index >= temp_count)
+                                        all_null = false;
+                                else if (live[index] & bi_writemask(ins, d))
+                                        all_null = false;
                         }
 
                         if (all_null && !bi_side_effects(ins))
index e43f5ec..36aaa73 100644 (file)
@@ -718,9 +718,8 @@ bi_lower_vector(bi_context *ctx)
                         bi_index src = I->src[0];
                         assert(src.offset == 0);
 
-                        for (unsigned i = 0; i < I->nr_dests; ++i) {
-                                if (bi_is_null(I->dest[i]))
-                                        continue;
+                        bi_foreach_dest(I, i) {
+                                assert(!bi_is_null(I->dest[i]));
 
                                 src.offset = i;
                                 bi_mov_i32_to(&b, I->dest[i], src);