summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_search.c
diff options
context:
space:
mode:
authorRob Clark <robclark@freedesktop.org>2016-05-07 13:01:24 -0400
committerRob Clark <robclark@freedesktop.org>2016-06-03 16:05:03 -0400
commitdfbae7d64f4d563bc65af338cdcb217f10474c1c (patch)
tree2a94671ec13b440c7c993cea08c28511cb205e30 /src/compiler/nir/nir_search.c
parenta64c7cd2bac33a3a2bf908b5ef538dff03b93b73 (diff)
downloadexternal_mesa3d-dfbae7d64f4d563bc65af338cdcb217f10474c1c.zip
external_mesa3d-dfbae7d64f4d563bc65af338cdcb217f10474c1c.tar.gz
external_mesa3d-dfbae7d64f4d563bc65af338cdcb217f10474c1c.tar.bz2
nir/algebraic: support for power-of-two optimizations
Some optimizations, like converting integer multiply/divide into left/ right shifts, have additional constraints on the search expression. Like requiring that a variable is a constant power of two. Support these cases by allowing a fxn name to be appended to the search var expression (ie. "a#32(is_power_of_two)"). Signed-off-by: Rob Clark <robclark@freedesktop.org> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Diffstat (limited to 'src/compiler/nir/nir_search.c')
-rw-r--r--src/compiler/nir/nir_search.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
index 2c2fd92..b21fb2c 100644
--- a/src/compiler/nir/nir_search.c
+++ b/src/compiler/nir/nir_search.c
@@ -127,6 +127,9 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
instr->src[src].src.ssa->parent_instr->type != nir_instr_type_load_const)
return false;
+ if (var->cond && !var->cond(instr, src, num_components, new_swizzle))
+ return false;
+
if (var->type != nir_type_invalid) {
if (instr->src[src].src.ssa->parent_instr->type != nir_instr_type_alu)
return false;