broadcom/compiler: optimize constant vfpack

total instructions in shared programs: 13733627 -> 13731663 (-0.01%)
instructions in affected programs: 174140 -> 172176 (-1.13%)
helped: 1597
HURT: 310
Instructions are helped.

total uniforms in shared programs: 3784601 -> 3780693 (-0.10%)
uniforms in affected programs: 58678 -> 54770 (-6.66%)
helped: 2886
HURT: 3
Uniforms are helped.

total max-temps in shared programs: 2322714 -> 2319942 (-0.12%)
max-temps in affected programs: 15729 -> 12957 (-17.62%)
helped: 2189
HURT: 1
Max-temps are helped.

total spills in shared programs: 6010 -> 6012 (0.03%)
spills in affected programs: 61 -> 63 (3.28%)
helped: 0
HURT: 1

total fills in shared programs: 13494 -> 13497 (0.02%)
fills in affected programs: 89 -> 92 (3.37%)
helped: 0
HURT: 1

total sfu-stalls in shared programs: 31521 -> 31584 (0.20%)
sfu-stalls in affected programs: 328 -> 391 (19.21%)
helped: 30
HURT: 94
Inconclusive result (%-change mean confidence interval includes 0).

total inst-and-stalls in shared programs: 13765148 -> 13763247 (-0.01%)
inst-and-stalls in affected programs: 174237 -> 172336 (-1.09%)
helped: 1551
HURT: 316
Inst-and-stalls are helped.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9681>
This commit is contained in:
Iago Toral Quiroga
2021-03-17 09:14:53 +01:00
committed by Marge Bot
parent b189409a46
commit 1c987f5db3
+25 -9
View File
@@ -27,10 +27,10 @@
* Identified sequences of ALU instructions that operate on constant operands
* and reduces them to a uniform load.
*
* Currently, this is useul to optimize the result of removing leading ldunifa
* instructions in the DCE pass, which can leave a series of constant additions
* that increment the unifa address by 4 for each leading ldunif removed. It
* helps turn this:
* This is useful, for example, to optimize the result of removing leading
* ldunifa instructions in the DCE pass, which can leave a series of constant
* additions that increment the unifa address by 4 for each leading ldunif
* removed. It helps turn this:
*
* nop t1; ldunif (0x00000004 / 0.000000)
* nop t2; ldunif (0x00000004 / 0.000000)
@@ -56,16 +56,32 @@
#include "v3d_compiler.h"
#include "util/half_float.h"
#include "util/u_math.h"
static bool
opt_constant_add(struct v3d_compile *c, struct qinst *inst, uint32_t *values)
opt_constant_add(struct v3d_compile *c, struct qinst *inst, union fi *values)
{
/* FIXME: handle more add operations */
struct qreg unif = { };
switch (inst->qpu.alu.add.op) {
case V3D_QPU_A_ADD:
c->cursor = vir_after_inst(inst);
unif = vir_uniform_ui(c, values[0] + values[1]);
unif = vir_uniform_ui(c, values[0].ui + values[1].ui);
break;
case V3D_QPU_A_VFPACK: {
assert(inst->qpu.alu.add.output_pack == V3D_QPU_PACK_NONE);
const uint32_t packed =
(((uint32_t)_mesa_float_to_half(values[1].f)) << 16) |
_mesa_float_to_half(values[0].f);
c->cursor = vir_after_inst(inst);
unif = vir_uniform_ui(c, packed);
break;
}
default:
return false;
}
@@ -103,12 +119,12 @@ try_opt_constant_alu(struct v3d_compile *c, struct qinst *inst)
}
assert(vir_get_nsrc(inst) <= 2);
uint32_t values[2];
union fi values[2];
for (int i = 0; i < vir_get_nsrc(inst); i++) {
if (inst->src[i].file == QFILE_SMALL_IMM &&
v3d_qpu_small_imm_unpack(c->devinfo,
inst->qpu.raddr_b,
&values[i])) {
&values[i].ui)) {
continue;
}
@@ -119,7 +135,7 @@ try_opt_constant_alu(struct v3d_compile *c, struct qinst *inst)
if ((def->qpu.sig.ldunif || def->qpu.sig.ldunifrf) &&
c->uniform_contents[def->uniform] == QUNIFORM_CONSTANT) {
values[i] = c->uniform_data[def->uniform];
values[i].ui = c->uniform_data[def->uniform];
continue;
}
}