nir/search: check for changes before adding uses to worklist

So it doesn't uselessly add instructions to the worklist.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7511>
This commit is contained in:
Rhys Perry
2020-11-04 13:12:47 +00:00
parent 556a20afe6
commit 7d8c06d484

View File

@@ -648,12 +648,16 @@ UNUSED static void dump_value(const nir_search_value *val)
}
static void
add_uses_to_worklist(nir_instr *instr, nir_instr_worklist *worklist)
add_uses_to_worklist(nir_instr *instr,
nir_instr_worklist *worklist,
struct util_dynarray *states,
const struct per_op_table *pass_op_table)
{
nir_ssa_def *def = nir_instr_ssa_def(instr);
nir_foreach_use_safe(use_src, def) {
nir_instr_worklist_push_tail(worklist, use_src->parent_instr);
if (nir_algebraic_automaton(use_src->parent_instr, states, pass_op_table))
nir_instr_worklist_push_tail(worklist, use_src->parent_instr);
}
}
@@ -669,15 +673,12 @@ nir_algebraic_update_automaton(nir_instr *new_instr,
/* Walk through the tree of uses of our new instruction's SSA value,
* recursively updating the automaton state until it stabilizes.
*/
add_uses_to_worklist(new_instr, automaton_worklist);
add_uses_to_worklist(new_instr, automaton_worklist, states, pass_op_table);
nir_instr *instr;
while ((instr = nir_instr_worklist_pop_head(automaton_worklist))) {
if (nir_algebraic_automaton(instr, states, pass_op_table)) {
nir_instr_worklist_push_tail(algebraic_worklist, instr);
add_uses_to_worklist(instr, automaton_worklist);
}
nir_instr_worklist_push_tail(algebraic_worklist, instr);
add_uses_to_worklist(instr, automaton_worklist, states, pass_op_table);
}
nir_instr_worklist_destroy(automaton_worklist);