mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
vc4: Optimize out adds of 0.
This commit is contained in:
parent
0401f55fff
commit
7e67ea994c
1 changed files with 26 additions and 0 deletions
|
|
@ -98,6 +98,18 @@ replace_with_mov(struct vc4_compile *c, struct qinst *inst, struct qreg arg)
|
|||
dump_to(c, inst);
|
||||
}
|
||||
|
||||
static bool
|
||||
add_replace_zero(struct vc4_compile *c,
|
||||
struct qinst **defs,
|
||||
struct qinst *inst,
|
||||
int arg)
|
||||
{
|
||||
if (!is_zero(c, defs, inst->src[arg]))
|
||||
return false;
|
||||
replace_with_mov(c, inst, inst->src[1 - arg]);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
fmul_replace_zero(struct vc4_compile *c,
|
||||
struct qinst **defs,
|
||||
|
|
@ -181,7 +193,21 @@ qir_opt_algebraic(struct vc4_compile *c)
|
|||
}
|
||||
break;
|
||||
|
||||
case QOP_ADD:
|
||||
if (add_replace_zero(c, defs, inst, 0) ||
|
||||
add_replace_zero(c, defs, inst, 1)) {
|
||||
progress = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case QOP_FADD:
|
||||
if (add_replace_zero(c, defs, inst, 0) ||
|
||||
add_replace_zero(c, defs, inst, 1)) {
|
||||
progress = true;
|
||||
break;
|
||||
}
|
||||
|
||||
/* FADD(a, FSUB(0, b)) -> FSUB(a, b) */
|
||||
if (inst->src[1].file == QFILE_TEMP &&
|
||||
defs[inst->src[1].index]->op == QOP_FSUB) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue