From 5a62d47762c917633bdd614a184273ed294d26e1 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Tue, 24 Sep 2024 13:07:45 +0200 Subject: [PATCH] broadcom/compiler: don't use small immediates in geometry stages Shader-db shows this is beneficial, even if it comes with a small increase in register pressure. total instructions in shared programs: 10889197 -> 10869857 (-0.18%) instructions in affected programs: 3625014 -> 3605674 (-0.53%) helped: 14911 HURT: 8324 Instructions are helped. total threads in shared programs: 431034 -> 431014 (<.01%) threads in affected programs: 40 -> 20 (-50.00%) helped: 0 HURT: 10 Threads are HURT. total uniforms in shared programs: 5308006 -> 5432767 (2.35%) uniforms in affected programs: 2204951 -> 2329712 (5.66%) helped: 9 HURT: 30766 Uniforms are HURT. total max-temps in shared programs: 2226471 -> 2235269 (0.40%) max-temps in affected programs: 272670 -> 281468 (3.23%) helped: 2372 HURT: 8479 Max-temps are HURT. total spills in shared programs: 4318 -> 4331 (0.30%) spills in affected programs: 39 -> 52 (33.33%) helped: 2 HURT: 7 total fills in shared programs: 6514 -> 6527 (0.20%) fills in affected programs: 42 -> 55 (30.95%) helped: 2 HURT: 7 total sfu-stalls in shared programs: 15166 -> 15808 (4.23%) sfu-stalls in affected programs: 2389 -> 3031 (26.87%) helped: 513 HURT: 944 Inconclusive result (%-change mean confidence interval includes 0). total inst-and-stalls in shared programs: 10904363 -> 10885665 (-0.17%) inst-and-stalls in affected programs: 3660930 -> 3642232 (-0.51%) helped: 14878 HURT: 8450 Inst-and-stalls are helped. total nops in shared programs: 183672 -> 184256 (0.32%) nops in affected programs: 12532 -> 13116 (4.66%) helped: 1841 HURT: 2251 Nops are HURT. Reviewed-by: Jose Maria Casanova Crespo Part-of: --- .../compiler/vir_opt_small_immediates.c | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/broadcom/compiler/vir_opt_small_immediates.c b/src/broadcom/compiler/vir_opt_small_immediates.c index 49773a8f85e..551bc1c8649 100644 --- a/src/broadcom/compiler/vir_opt_small_immediates.c +++ b/src/broadcom/compiler/vir_opt_small_immediates.c @@ -32,27 +32,10 @@ static bool debug; -static bool +static inline bool skip_inst(struct qinst *inst) { - if (inst->qpu.type != V3D_QPU_INSTR_TYPE_ALU) - return true; - - if (!vir_is_add(inst)) - return false; - - switch (inst->qpu.alu.add.op) { - case V3D_QPU_A_LDVPMV_IN: - case V3D_QPU_A_LDVPMG_IN: - case V3D_QPU_A_LDVPMD_IN: - case V3D_QPU_A_LDVPMP: - case V3D_QPU_A_STVPMV: - case V3D_QPU_A_STVPMD: - case V3D_QPU_A_STVPMP: - return true; - default: - return false; - } + return inst->qpu.type != V3D_QPU_INSTR_TYPE_ALU; } bool @@ -60,6 +43,14 @@ vir_opt_small_immediates(struct v3d_compile *c) { bool progress = false; + /* Shader-db shows that small immediates generally lead to higher + * instruction counts for geometry stages. + */ + if (c->s->info.stage != MESA_SHADER_FRAGMENT && + c->s->info.stage != MESA_SHADER_COMPUTE) { + return progress; + } + vir_for_each_inst_inorder(inst, c) { if (skip_inst(inst)) continue;