diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2019-02-20 14:00:50 -0800 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2019-03-26 10:29:21 -0700 |
commit | ab8364c5889db53f46d5589ae247fede5bf26377 (patch) | |
tree | 1dc611aeaf1508b1957019d207e8f5398897288d | |
parent | bd821d7c5178ce28ad69b75620f05a2e3680a59a (diff) |
nir/search: Conditionally allow destination saturate on root of expression tree
-rw-r--r-- | src/compiler/nir/nir_search.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c index 363d9ba247e..0acb3c3cc9f 100644 --- a/src/compiler/nir/nir_search.c +++ b/src/compiler/nir/nir_search.c @@ -43,7 +43,7 @@ struct match_state { static bool match_expression(const nir_search_expression *expr, nir_alu_instr *instr, unsigned num_components, const uint8_t *swizzle, - struct match_state *state); + struct match_state *state, bool allow_destinaion_saturate); static const uint8_t identity_swizzle[NIR_MAX_VEC_COMPONENTS] = { 0, 1, 2, 3 }; @@ -222,7 +222,7 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src, 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); + num_components, new_swizzle, state, false); case nir_search_value_variable: { nir_search_variable *var = nir_search_value_as_variable(value); @@ -315,7 +315,7 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src, static bool match_expression(const nir_search_expression *expr, nir_alu_instr *instr, unsigned num_components, const uint8_t *swizzle, - struct match_state *state) + struct match_state *state, bool allow_destinaion_saturate) { if (expr->cond && !expr->cond(instr)) return false; @@ -332,7 +332,9 @@ match_expression(const nir_search_expression *expr, nir_alu_instr *instr, if (state->inexact_match && state->has_exact_alu) return false; - assert(!instr->dest.saturate); + if (!allow_destinaion_saturate && instr->dest.saturate) + return false; + assert(nir_op_infos[instr->op].num_inputs > 0); /* If we have an explicitly sized destination, we can only handle the @@ -513,7 +515,7 @@ nir_replace_instr(nir_builder *build, nir_alu_instr *instr, memset(&state, 0, sizeof(state)); if (!match_expression(search, instr, instr->dest.dest.ssa.num_components, - swizzle, &state)) + swizzle, &state, false)) return NULL; build->cursor = nir_before_instr(&instr->instr); |