Mesa (master): nir/search: check for changes before adding uses to worklist

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Nov 20 14:40:18 UTC 2020


Module: Mesa
Branch: master
Commit: 7d8c06d484fdb9514d49ead04637bb554e25b01d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7d8c06d484fdb9514d49ead04637bb554e25b01d

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Wed Nov  4 13:12:47 2020 +0000

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 at gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7511>

---

 src/compiler/nir/nir_search.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
index 735e2c7d6c6..04ad2490a3f 100644
--- a/src/compiler/nir/nir_search.c
+++ b/src/compiler/nir/nir_search.c
@@ -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);



More information about the mesa-commit mailing list