pan/mdg: emit REGISTER_UNUSED on unused ALU src2
authorItalo Nicola <italonicola@collabora.com>
Thu, 30 Jul 2020 23:24:06 +0000 (23:24 +0000)
committerMarge Bot <eric+marge@anholt.net>
Fri, 31 Jul 2020 00:25:21 +0000 (00:25 +0000)
This saves power and time by skipping a roundtrip to the register file.

Signed-off-by: Italo Nicola <italonicola@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6128>

src/panfrost/midgard/helpers.h
src/panfrost/midgard/midgard_emit.c

index 36d64957f4729b73f811fabf85b247e671f16f66..6f6f82cc70aa302c981d71abae32c69474fd2964 100644 (file)
 /* 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
index 2882fae1e9e93e5188c32dad888c53dba2e153c4..8c08818214c72e30c26ab19f4fc8653bfb19124b 100644 (file)
@@ -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 :