diff options
author | Eric Anholt <[email protected]> | 2014-10-09 15:10:52 +0200 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-10-09 21:47:06 +0200 |
commit | 7e67ea994c34a6ebbaeb6a097036702c7a96496f (patch) | |
tree | 9a538b73b2618d0fe5e1157d1b642504a6a687bc | |
parent | 0401f55fffc6e77807e6987e23d2709a1599d61e (diff) |
vc4: Optimize out adds of 0.
-rw-r--r-- | src/gallium/drivers/vc4/vc4_opt_algebraic.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_opt_algebraic.c b/src/gallium/drivers/vc4/vc4_opt_algebraic.c index 435814e6912..c1144583f63 100644 --- a/src/gallium/drivers/vc4/vc4_opt_algebraic.c +++ b/src/gallium/drivers/vc4/vc4_opt_algebraic.c @@ -99,6 +99,18 @@ replace_with_mov(struct vc4_compile *c, struct qinst *inst, struct qreg arg) } 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, struct qinst *inst, @@ -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) { |