pan/bi: Scalarize bi_opt_cse
authorAlyssa Rosenzweig <alyssa@collabora.com>
Wed, 11 May 2022 16:24:22 +0000 (12:24 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 19 May 2022 16:08:26 +0000 (16:08 +0000)
Reduces memory footprint.

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

src/panfrost/bifrost/bi_opt_cse.c

index 7c8bc42..bf1122e 100644 (file)
@@ -157,7 +157,7 @@ bi_opt_cse(bi_context *ctx)
         struct set *instr_set = _mesa_set_create(NULL, hash_instr, instrs_equal);
 
         bi_foreach_block(ctx, block) {
-                bi_index *replacement = calloc(sizeof(bi_index), ((ctx->ssa_alloc + 1) << 2));
+                bi_index *replacement = calloc(sizeof(bi_index), ctx->ssa_alloc);
                 _mesa_set_clear(instr_set, NULL);
 
                 bi_foreach_instr_in_block(block, instr) {
@@ -170,7 +170,7 @@ bi_opt_cse(bi_context *ctx)
                                 if (!bi_is_ssa(instr->src[s]))
                                         continue;
 
-                                bi_index repl = replacement[bi_word_node(instr->src[s])];
+                                bi_index repl = replacement[instr->src[s].value];
                                 if (!bi_is_null(repl))
                                         instr->src[s] = bi_replace_index(instr->src[s], repl);
                         }
@@ -186,7 +186,7 @@ bi_opt_cse(bi_context *ctx)
 
                                 bi_foreach_dest(instr, d) {
                                         if (!bi_is_null(instr->dest[d]))
-                                                replacement[bi_word_node(instr->dest[d])] = match->dest[d];
+                                                replacement[instr->dest[d].value] = match->dest[d];
                                 }
                         }
                 }