From f5709f17a2739aeaaba29689144118b68ddc5ba8 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 3 Feb 2021 14:33:48 -0500 Subject: [PATCH] pan/bi: Add side_effects helper DCE needs to be tuned for this. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bir.c | 33 +++++++++++++++++++++++++++++++++ src/panfrost/bifrost/compiler.h | 1 + 2 files changed, 34 insertions(+) diff --git a/src/panfrost/bifrost/bir.c b/src/panfrost/bifrost/bir.c index 4012eeb6cab..544a4648cf7 100644 --- a/src/panfrost/bifrost/bir.c +++ b/src/panfrost/bifrost/bir.c @@ -152,3 +152,36 @@ bi_next_clause(bi_context *ctx, pan_block *block, bi_clause *clause) return NULL; } + +/* Does an instruction have a side effect not captured by its register + * destination? Applies to certain message-passing instructions only, used in + * dead code elimation */ + +bool +bi_side_effects(enum bi_opcode op) +{ + switch (bi_opcode_props[op].message) { + case BIFROST_MESSAGE_NONE: + case BIFROST_MESSAGE_VARYING: + case BIFROST_MESSAGE_ATTRIBUTE: + case BIFROST_MESSAGE_TEX: + case BIFROST_MESSAGE_VARTEX: + case BIFROST_MESSAGE_LOAD: + case BIFROST_MESSAGE_64BIT: + return false; + + case BIFROST_MESSAGE_STORE: + case BIFROST_MESSAGE_ATOMIC: + case BIFROST_MESSAGE_BARRIER: + case BIFROST_MESSAGE_BLEND: + case BIFROST_MESSAGE_Z_STENCIL: + case BIFROST_MESSAGE_ATEST: + case BIFROST_MESSAGE_JOB: + return true; + + case BIFROST_MESSAGE_TILE: + return (op != BI_OPCODE_LD_TILE); + } + + unreachable("Invalid message type"); +} diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 8b21728e31e..979927d0d02 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -708,6 +708,7 @@ 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); void bi_print_instr(bi_instr *I, FILE *fp); void bi_print_slots(bi_registers *regs, FILE *fp);