pan/bi: Inline `bytemask of read components`
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 18 Feb 2021 21:26:02 +0000 (16:26 -0500)
committerMarge Bot <eric+marge@anholt.net>
Mon, 22 Feb 2021 19:17:50 +0000 (19:17 +0000)
Only used in one place (and should never be used elsewhere -- even this
use is questionable). By inlining we avoid O(N^2) behaviour on the
number of sources in liveness updates.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9164>

src/panfrost/bifrost/bi_liveness.c
src/panfrost/bifrost/bir.c
src/panfrost/bifrost/compiler.h

index f4c9cec..2b8c569 100644 (file)
@@ -32,10 +32,12 @@ bi_liveness_ins_update(uint16_t *live, bi_instr *ins, unsigned max)
         pan_liveness_kill(live, bi_get_node(ins->dest[0]), max, bi_writemask(ins));
 
         bi_foreach_src(ins, src) {
-                unsigned node = bi_get_node(ins->src[src]);
-                unsigned bytemask = bi_bytemask_of_read_components(ins, ins->src[src]);
+                unsigned count = bi_count_read_registers(ins, src);
+                unsigned rmask = (1 << (4 * count)) - 1;
+                uint16_t mask = (rmask << (4 * ins->src[src].offset));
 
-                pan_liveness_gen(live, node, max, bytemask);
+                unsigned node = bi_get_node(ins->src[src]);
+                pan_liveness_gen(live, node, max, mask);
         }
 }
 
index 544a464..aa5bf87 100644 (file)
@@ -92,22 +92,6 @@ bi_count_read_registers(bi_instr *ins, unsigned s)
                 return 1;
 }
 
-uint16_t
-bi_bytemask_of_read_components(bi_instr *ins, bi_index node)
-{
-        uint16_t mask = 0x0;
-
-        bi_foreach_src(ins, s) {
-                if (!bi_is_equiv(ins->src[s], node)) continue;
-
-                unsigned count = bi_count_read_registers(ins, s);
-                unsigned rmask = (1 << (4 * count)) - 1;
-                mask |= (rmask << (4 * node.offset));
-        }
-
-        return mask;
-}
-
 unsigned
 bi_writemask(bi_instr *ins)
 {
index e569aec..9a82d0f 100644 (file)
@@ -730,7 +730,6 @@ pan_next_block(pan_block *block)
 
 bool bi_has_arg(bi_instr *ins, bi_index arg);
 unsigned bi_count_read_registers(bi_instr *ins, unsigned src);
-uint16_t bi_bytemask_of_read_components(bi_instr *ins, bi_index node);
 unsigned bi_writemask(bi_instr *ins);
 bi_clause * bi_next_clause(bi_context *ctx, pan_block *block, bi_clause *clause);
 bool bi_side_effects(enum bi_opcode op);