nir: Skip common instructions when comparing deref paths
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Fri, 10 Aug 2018 23:04:04 +0000 (16:04 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Wed, 22 Aug 2018 21:41:26 +0000 (14:41 -0700)
commit8364ec3fcee692d70b7d653dd433a3194d88dd82
treebfdf33fb145c2a06e7936890a31835a6b154e428
parent5196041e937584d6bab940c26eb608dcfab7129b
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@jlekstrand.net>
src/compiler/nir/nir_deref.c