summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorRhys Perry <[email protected]>2019-08-05 15:24:18 +0100
committerDaniel Schürmann <[email protected]>2019-08-20 17:40:05 +0200
commit911a1dfad25feb32e7030b54abd0c69e415f9cc7 (patch)
treee6cd3854d0b0c6d38f2fb633910a82e8a75f7a06 /src/compiler
parent9c40ad49d5ae69b6aa6c51b464df5ba6ce78876b (diff)
nir/lcssa: allow to create LCSSA phis for loop-invariant booleans
ACO depends on LCSSA phis for divergent booleans to work correctly. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir.h2
-rw-r--r--src/compiler/nir/nir_to_lcssa.c8
2 files changed, 7 insertions, 3 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 614644525d7..57326fe180e 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3923,7 +3923,7 @@ bool nir_repair_ssa_impl(nir_function_impl *impl);
bool nir_repair_ssa(nir_shader *shader);
void nir_convert_loop_to_lcssa(nir_loop *loop);
-bool nir_convert_to_lcssa(nir_shader *shader, bool skip_invariants);
+bool nir_convert_to_lcssa(nir_shader *shader, bool skip_invariants, bool skip_bool_invariants);
/* If phi_webs_only is true, only convert SSA values involved in phi nodes to
* registers. If false, convert all values (even those not involved in a phi
diff --git a/src/compiler/nir/nir_to_lcssa.c b/src/compiler/nir/nir_to_lcssa.c
index e66d89a43ba..e5b760c706f 100644
--- a/src/compiler/nir/nir_to_lcssa.c
+++ b/src/compiler/nir/nir_to_lcssa.c
@@ -48,6 +48,7 @@ typedef struct {
/* Whether to skip loop invariant variables */
bool skip_invariants;
+ bool skip_bool_invariants;
bool progress;
} lcssa_state;
@@ -193,7 +194,8 @@ convert_loop_exit_for_ssa(nir_ssa_def *def, void *void_state)
bool all_uses_inside_loop = true;
/* Don't create LCSSA-Phis for loop-invariant variables */
- if (state->skip_invariants) {
+ if (state->skip_invariants &&
+ (def->bit_size != 1 || state->skip_bool_invariants)) {
assert(def->parent_instr->pass_flags != undefined);
if (def->parent_instr->pass_flags == invariant)
return true;
@@ -361,6 +363,7 @@ nir_convert_loop_to_lcssa(nir_loop *loop)
state->loop = loop;
state->shader = impl->function->shader;
state->skip_invariants = false;
+ state->skip_bool_invariants = false;
nir_foreach_block_in_cf_node (block, &loop->cf_node) {
nir_foreach_instr(instr, block)
@@ -371,12 +374,13 @@ nir_convert_loop_to_lcssa(nir_loop *loop)
}
bool
-nir_convert_to_lcssa(nir_shader *shader, bool skip_invariants)
+nir_convert_to_lcssa(nir_shader *shader, bool skip_invariants, bool skip_bool_invariants)
{
bool progress = false;
lcssa_state *state = rzalloc(NULL, lcssa_state);
state->shader = shader;
state->skip_invariants = skip_invariants;
+ state->skip_bool_invariants = skip_bool_invariants;
nir_foreach_function(function, shader) {
if (function->impl == NULL)