From 4e6b675974261173d2cb08edf5fb4d01669f682f Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Wed, 26 Jun 2024 13:45:14 +0200 Subject: [PATCH] broadcom/compiler: drop multop if we dce umul24 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We always emit multop+umul24 to implement integer multiply and this is the only scenario in which we use multop, so if we decide to DCE umul24 we should also DCE the previous multop. Reviewed-by: Alejandro PiƱeiro Part-of: --- src/broadcom/compiler/vir_opt_dead_code.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/broadcom/compiler/vir_opt_dead_code.c b/src/broadcom/compiler/vir_opt_dead_code.c index fd1af944427..6d05385b1da 100644 --- a/src/broadcom/compiler/vir_opt_dead_code.c +++ b/src/broadcom/compiler/vir_opt_dead_code.c @@ -182,6 +182,7 @@ vir_opt_dead_code(struct v3d_compile *c) } } + struct qinst *last_multop = NULL; vir_for_each_block(block, c) { struct qinst *last_flags_write = NULL; c->cur_block = block; @@ -192,6 +193,11 @@ vir_opt_dead_code(struct v3d_compile *c) if (v3d_qpu_reads_flags(&inst->qpu)) last_flags_write = NULL; + if (inst->qpu.type == V3D_QPU_INSTR_TYPE_ALU && + inst->qpu.alu.mul.op == V3D_QPU_M_MULTOP) { + last_multop = inst; + } + if (inst->dst.file != QFILE_NULL && !(inst->dst.file == QFILE_TEMP && !used[inst->dst.index])) { @@ -263,6 +269,16 @@ vir_opt_dead_code(struct v3d_compile *c) continue; } + /* If we drop umul24 we should also drop the previous + * multop that we emit with it. + */ + if (inst->qpu.type == V3D_QPU_INSTR_TYPE_ALU && + inst->qpu.alu.mul.op == V3D_QPU_M_UMUL24 && + last_multop) { + dce(c, last_multop); + last_multop = NULL; + } + assert(inst != last_flags_write); dce(c, inst); progress = true;