summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir/nir_search.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-01-22 14:15:27 -0800
committerJason Ekstrand <[email protected]>2015-01-29 17:07:45 -0800
commitd8999bcdce6a3c8ab63f06c7028fd6e927bb9acb (patch)
tree6230d336d20d51c99af44b788093ceb31fd1659f /src/glsl/nir/nir_search.c
parent5ab1489ae62fa68e45664588d8809b3d667d7425 (diff)
nir/search: Add support for matching unknown constants
There are some algebraic transformations that we want to do but only if certain things are constants. For instance, we may want to replace a * (b + c) with (a * b) + (a * c) as long as a and either b or c is constant. While this generates more instructions, some of it will get constant folded. nir_algebraic.py doesn't handle this yet, but that's ok because the C language will make sure that false is the default for now. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir_search.c')
-rw-r--r--src/glsl/nir/nir_search.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/glsl/nir/nir_search.c b/src/glsl/nir/nir_search.c
index 18e0330e4ae..ec898174364 100644
--- a/src/glsl/nir/nir_search.c
+++ b/src/glsl/nir/nir_search.c
@@ -78,6 +78,10 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
return true;
} else {
+ if (var->is_constant &&
+ instr->src[src].src.ssa->parent_instr->type != nir_instr_type_load_const)
+ return false;
+
state->variables_seen |= (1 << var->variable);
state->variables[var->variable].src = instr->src[src].src;
state->variables[var->variable].abs = false;
@@ -236,6 +240,8 @@ construct_value(const nir_search_value *value, nir_alu_type type,
nir_alu_src val;
nir_alu_src_copy(&val, &state->variables[var->variable], mem_ctx);
+ assert(!var->is_constant);
+
return val;
}