summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2019-02-20 13:50:06 -0800
committerIan Romanick <ian.d.romanick@intel.com>2019-03-26 10:29:22 -0700
commit69fb575cfff732f19c76c5797481f7a73cbe04c9 (patch)
treec259fbf2277a7549304d8068d36eb78c42e66847
parentab8364c5889db53f46d5589ae247fede5bf26377 (diff)
nir/search: Allow source modifiers on variables
Source modifiers on expressions are still not allowed. A search pattern like ('fadd', a, a) will match ('fadd', -X, -X), but it will not match ('fadd', -X, X).
-rw-r--r--src/compiler/nir/nir_search.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
index 0acb3c3cc9f8..be87d4dbe651 100644
--- a/src/compiler/nir/nir_search.c
+++ b/src/compiler/nir/nir_search.c
@@ -220,6 +220,9 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
if (instr->src[src].src.ssa->parent_instr->type != nir_instr_type_alu)
return false;
+ if (instr->src[src].abs || instr->src[src].negate)
+ return false;
+
return match_expression(nir_search_value_as_expression(value),
nir_instr_as_alu(instr->src[src].src.ssa->parent_instr),
num_components, new_swizzle, state, false);
@@ -235,7 +238,9 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
if (state->variables[var->variable].src.ssa != instr->src[src].src.ssa)
return false;
- assert(!instr->src[src].abs && !instr->src[src].negate);
+ if (state->variables[var->variable].abs != instr->src[src].abs ||
+ state->variables[var->variable].negate != instr->src[src].negate)
+ return false;
for (unsigned i = 0; i < num_components; ++i) {
if (state->variables[var->variable].swizzle[i] != new_swizzle[i])
@@ -257,8 +262,8 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
state->variables_seen |= (1 << var->variable);
state->variables[var->variable].src = instr->src[src].src;
- state->variables[var->variable].abs = false;
- state->variables[var->variable].negate = false;
+ state->variables[var->variable].abs = instr->src[src].abs;
+ state->variables[var->variable].negate = instr->src[src].negate;
state->is_ssa[var->variable] = instr->src[src].src.is_ssa;
for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; ++i) {