summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_opt_algebraic.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_opt_algebraic.c')
-rw-r--r--src/gallium/drivers/vc4/vc4_opt_algebraic.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/gallium/drivers/vc4/vc4_opt_algebraic.c b/src/gallium/drivers/vc4/vc4_opt_algebraic.c
index 4376c7ba08f..d36bb2d6596 100644
--- a/src/gallium/drivers/vc4/vc4_opt_algebraic.c
+++ b/src/gallium/drivers/vc4/vc4_opt_algebraic.c
@@ -60,23 +60,33 @@ dump_to(struct vc4_compile *c, struct qinst *inst)
}
static bool
+is_constant_value(struct vc4_compile *c, struct qinst **defs, struct qreg reg,
+ uint32_t val)
+{
+ if (reg.file == QFILE_UNIF &&
+ c->uniform_contents[reg.index] == QUNIFORM_CONSTANT &&
+ c->uniform_data[reg.index] == val) {
+ return true;
+ }
+
+ if (reg.file == QFILE_SMALL_IMM && reg.index == val)
+ return true;
+
+ return false;
+}
+
+static bool
is_zero(struct vc4_compile *c, struct qinst **defs, struct qreg reg)
{
reg = qir_follow_movs(defs, reg);
-
- return (reg.file == QFILE_UNIF &&
- c->uniform_contents[reg.index] == QUNIFORM_CONSTANT &&
- c->uniform_data[reg.index] == 0);
+ return is_constant_value(c, defs, reg, 0);
}
static bool
is_1f(struct vc4_compile *c, struct qinst **defs, struct qreg reg)
{
reg = qir_follow_movs(defs, reg);
-
- return (reg.file == QFILE_UNIF &&
- c->uniform_contents[reg.index] == QUNIFORM_CONSTANT &&
- c->uniform_data[reg.index] == fui(1.0));
+ return is_constant_value(c, defs, reg, fui(1.0));
}
static void