diff options
-rw-r--r-- | src/compiler/nir/nir_opt_dead_cf.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/compiler/nir/nir_opt_dead_cf.c b/src/compiler/nir/nir_opt_dead_cf.c index 33f3565c564..0a5c4a5de3c 100644 --- a/src/compiler/nir/nir_opt_dead_cf.c +++ b/src/compiler/nir/nir_opt_dead_cf.c @@ -355,11 +355,22 @@ opt_dead_cf_impl(nir_function_impl *impl) if (progress) { nir_metadata_preserve(impl, nir_metadata_none); - } else { + + /* The CF manipulation code called by this pass is smart enough to keep + * from breaking any SSA use/def chains by replacing any uses of removed + * instructions with SSA undefs. However, it's not quite smart enough + * to always preserve the dominance properties. In particular, if you + * remove the one break from a loop, stuff in the loop may still be used + * outside the loop even though there's no path between the two. We can + * easily fix these issues by calling nir_repair_ssa which will ensure + * that the dominance properties hold. + */ + nir_repair_ssa_impl(impl); + } else { #ifndef NDEBUG impl->valid_metadata &= ~nir_metadata_not_properly_reset; #endif - } + } return progress; } |