summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_repair_ssa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/nir/nir_repair_ssa.c')
-rw-r--r--src/compiler/nir/nir_repair_ssa.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_repair_ssa.c b/src/compiler/nir/nir_repair_ssa.c
index b4d22d91c27..f182818374d 100644
--- a/src/compiler/nir/nir_repair_ssa.c
+++ b/src/compiler/nir/nir_repair_ssa.c
@@ -77,6 +77,15 @@ repair_ssa_def(nir_ssa_def *def, void *void_state)
}
}
+ nir_foreach_if_use(src, def) {
+ nir_block *block_before_if =
+ nir_cf_node_as_block(nir_cf_node_prev(&src->parent_if->cf_node));
+ if (!nir_block_dominates(def->parent_instr->block, block_before_if)) {
+ is_valid = false;
+ break;
+ }
+ }
+
if (is_valid)
return true;
@@ -98,6 +107,15 @@ repair_ssa_def(nir_ssa_def *def, void *void_state)
}
}
+ nir_foreach_if_use_safe(src, def) {
+ nir_block *block_before_if =
+ nir_cf_node_as_block(nir_cf_node_prev(&src->parent_if->cf_node));
+ if (!nir_block_dominates(def->parent_instr->block, block_before_if)) {
+ nir_if_rewrite_condition(src->parent_if, nir_src_for_ssa(
+ nir_phi_builder_value_get_block_def(val, block_before_if)));
+ }
+ }
+
return true;
}