From: Italo Nicola Date: Thu, 30 Jul 2020 23:24:06 +0000 (+0000) Subject: pan/mdg: emit REGISTER_UNUSED on unused ALU src2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a91011c9eca0e561475e476b7b6ab5da48a412c7;p=mesa.git pan/mdg: emit REGISTER_UNUSED on unused ALU src2 This saves power and time by skipping a roundtrip to the register file. Signed-off-by: Italo Nicola Reviewed-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/midgard/helpers.h b/src/panfrost/midgard/helpers.h index 36d64957f47..6f6f82cc70a 100644 --- a/src/panfrost/midgard/helpers.h +++ b/src/panfrost/midgard/helpers.h @@ -143,6 +143,9 @@ /* Uniforms are begin at (REGISTER_UNIFORMS - uniform_count) */ #define REGISTER_UNIFORMS 24 +/* r24 and r25 are special registers that only exist during the pipeline, + * by using them when we don't care about the register we skip a roundtrip + * to the register file. */ #define REGISTER_UNUSED 24 #define REGISTER_CONSTANT 26 #define REGISTER_LDST_BASE 26 diff --git a/src/panfrost/midgard/midgard_emit.c b/src/panfrost/midgard/midgard_emit.c index 2882fae1e9e..8c08818214c 100644 --- a/src/panfrost/midgard/midgard_emit.c +++ b/src/panfrost/midgard/midgard_emit.c @@ -736,15 +736,19 @@ emit_alu_bundle(compiler_context *ctx, /* Check if this instruction has registers */ if (ins->compact_branch) continue; + unsigned src2_reg = REGISTER_UNUSED; + if (ins->has_inline_constant) + src2_reg = ins->inline_constant >> 11; + else if (ins->src[1] != ~0) + src2_reg = SSA_REG_FROM_FIXED(ins->src[1]); + /* Otherwise, just emit the registers */ uint16_t reg_word = 0; midgard_reg_info registers = { .src1_reg = (ins->src[0] == ~0 ? REGISTER_UNUSED : SSA_REG_FROM_FIXED(ins->src[0])), - .src2_reg = (ins->src[1] == ~0 ? - ins->inline_constant >> 11 : - SSA_REG_FROM_FIXED(ins->src[1])), + .src2_reg = src2_reg, .src2_imm = ins->has_inline_constant, .out_reg = (ins->dest == ~0 ? REGISTER_UNUSED :