OSDN Git Service

nir/deref: Rematerialize parents in rematerialize_derefs_in_use_blocks
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 11 Feb 2019 04:23:01 +0000 (22:23 -0600)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 15 Feb 2019 11:38:47 +0000 (11:38 +0000)
commit3545986962a3a8e0937388d05ac304e4e559a082
treee5633aaf695aceadfe57cc5af0ca1ef1f228a1c5
parenta9c0e146efced68eab2de112304eb6acc0b78c67
nir/deref: Rematerialize parents in rematerialize_derefs_in_use_blocks

When nir_rematerialize_derefs_in_use_blocks_impl was first written, I
attempted to optimize things a bit by not bothering to re-materialize
the sources of deref instructions figuring that the final caller would
take care of that.  However, in the case of more complex deref chains
where the first link or two lives in block A and then another link and
the load/store_deref intrinsic live in block B it doesn't work.  The
code in rematerialize_deref_in_block looks at the tail of the chain,
sees that it's already in block B and skips it, not realizing that part
of the chain also lives in block A.

The easy solution here is to just rematerialize deref sources of deref
instructions as well.  This may potentially lead to a few more deref
instructions being created by the conditions required for that to
actually happen are fairly unlikely and, thanks to the caching, it's all
linear time regardless.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109603
Fixes: 7d1d1208c2b "nir: Add a small pass to rematerialize derefs per-block"
Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
(cherry picked from commit 9e6a6ef0d45a5bb61a541c495fe12e54e646ecfe)
src/compiler/nir/nir_deref.c