From ef726afd59855759cc481c67603f4d954e4ede15 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 2 Jan 2025 15:00:15 +0000 Subject: [PATCH] nir/search: check variable requirements even if it's already seen Even if it's already seen, the variable might have some unchecked requirements. Signed-off-by: Rhys Perry Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12320 Backport-to: 25.1 Reviewed-by: Georg Lehmann Part-of: (cherry picked from commit 7ed9fdf85b9b56b839356d0e98d5b2b3e2612d7f) --- .pick_status.json | 2 +- src/compiler/nir/nir_search.c | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index fe611b0f2da..221cb4a47b1 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -44,7 +44,7 @@ "description": "nir/search: check variable requirements even if it's already seen", "nominated": true, "nomination_type": 4, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c index 55c1f17107a..8faed29201e 100644 --- a/src/compiler/nir/nir_search.c +++ b/src/compiler/nir/nir_search.c @@ -274,6 +274,18 @@ match_value(const nir_algebraic_table *table, nir_search_variable *var = nir_search_value_as_variable(value); assert(var->variable < NIR_SEARCH_MAX_VARIABLES); + if (var->is_constant && + instr->src[src].src.ssa->parent_instr->type != nir_instr_type_load_const) + return false; + + if (var->cond_index != -1 && !table->variable_cond[var->cond_index](state->range_ht, instr, + src, num_components, new_swizzle)) + return false; + + if (var->type != nir_type_invalid && + !src_is_type(instr->src[src].src, var->type)) + return false; + if (state->variables_seen & (1 << var->variable)) { if (state->variables[var->variable].src.ssa != instr->src[src].src.ssa) return false; @@ -285,18 +297,6 @@ match_value(const nir_algebraic_table *table, return true; } else { - if (var->is_constant && - instr->src[src].src.ssa->parent_instr->type != nir_instr_type_load_const) - return false; - - if (var->cond_index != -1 && !table->variable_cond[var->cond_index](state->range_ht, instr, - src, num_components, new_swizzle)) - return false; - - if (var->type != nir_type_invalid && - !src_is_type(instr->src[src].src, var->type)) - return false; - state->variables_seen |= (1 << var->variable); state->variables[var->variable].src = instr->src[src].src;