Mesa (master): nir: Skip common instructions when comparing deref paths

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 22 21:41:55 UTC 2018


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

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Fri Aug 10 16:04:04 2018 -0700

nir: Skip common instructions when comparing deref paths

Deref paths may share the same deref instructions in their chains,
e.g.

    ssa_100 = deref_var A
    ssa_101 = deref_struct "array_field" of ssa_100
    ssa_102 = deref_array "[1]" of ssa_101
    ssa_103 = deref_struct "field_a" of ssa_102
    ssa_104 = deref_struct "field_a" of ssa_103

when comparing the two last deref instructions, their paths will share
a common sequence ssa_100, ssa_101, ssa_102.  This patch skips to next
iteration if the deref instructions are the same.  Path[0] (the var)
is still handled specially, so in the case above, only ssa_101 and
ssa_102 will be skipped.

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

---

 src/compiler/nir/nir_deref.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c
index d013b423a8..c8851688f9 100644
--- a/src/compiler/nir/nir_deref.c
+++ b/src/compiler/nir/nir_deref.c
@@ -294,6 +294,9 @@ nir_compare_deref_paths(nir_deref_path *a_path,
       nir_deref_instr *a_tail = *(a_p++);
       nir_deref_instr *b_tail = *(b_p++);
 
+      if (a_tail == b_tail)
+         continue;
+
       switch (a_tail->deref_type) {
       case nir_deref_type_array:
       case nir_deref_type_array_wildcard: {




More information about the mesa-commit mailing list