Mesa (master): nir/copy_prop_vars: prefer using entries from equal derefs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Mar 1 07:59:03 UTC 2019


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

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Tue Jan 29 12:39:28 2019 -0800

nir/copy_prop_vars: prefer using entries from equal derefs

When looking up an entry to use, always prefer an equal match, as it
more likely to contain reusable SSA or derefs to propagate.

This will be necessary when adding entries with array derefs of
vectors, because we don't want the vector if the equal entry (an array
deref of that vector) is present.

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

---

 src/compiler/nir/nir_opt_copy_prop_vars.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c b/src/compiler/nir/nir_opt_copy_prop_vars.c
index b95a455a109..7fc84083ea6 100644
--- a/src/compiler/nir/nir_opt_copy_prop_vars.c
+++ b/src/compiler/nir/nir_opt_copy_prop_vars.c
@@ -302,12 +302,17 @@ lookup_entry_for_deref(struct util_dynarray *copies,
                        nir_deref_instr *deref,
                        nir_deref_compare_result allowed_comparisons)
 {
+   struct copy_entry *entry = NULL;
    util_dynarray_foreach(copies, struct copy_entry, iter) {
-      if (nir_compare_derefs(iter->dst, deref) & allowed_comparisons)
-         return iter;
+      nir_deref_compare_result result = nir_compare_derefs(iter->dst, deref);
+      if (result & allowed_comparisons) {
+         entry = iter;
+         if (result & nir_derefs_equal_bit)
+            break;
+         /* Keep looking in case we have an equal match later in the array. */
+      }
    }
-
-   return NULL;
+   return entry;
 }
 
 static struct copy_entry *




More information about the mesa-commit mailing list