nir/repair_ssa: Replace the unreachable check with the phi builder
authorJason Ekstrand <jason@jlekstrand.net>
Mon, 9 Sep 2019 18:38:37 +0000 (13:38 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Mon, 23 Sep 2019 16:19:24 +0000 (16:19 +0000)
commitd63162cff0e0922fc3c2ef5dfd4402004caf141e
treee38d0ca1e8a8849a5c0ebe3450dcf7a21d53dc71
parent2c050b49b3d776f054f1265d5523cabb61f22fc3
nir/repair_ssa: Replace the unreachable check with the phi builder

In a3268599f3c9, I attempted to fix nir_repair_ssa for unreachable
blocks.  However, that commit missed the possibility that the use is in
a block which, itself, is unreachable.  In this case, we can end up in
an infinite loop trying to replace a def with itself.  Even though a
no-op replacement is a fine operation, it keeps extending the end of the
uses list as we're walking it.  Instead of explicitly checking for the
group of conditions, just check if the phi builder gives us a different
def.  That's guaranteed to be 100% reliable and, while it lacks symmetry
with the is_valid checks, should be more reliable.

Fixes: a3268599 "nir/repair_ssa: Repair dominance for unreachable..."
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/compiler/nir/nir_repair_ssa.c