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 <cwabbott0@gmail.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:

committed by
Daniel Schürmann

parent
9c40ad49d5
commit
911a1dfad2
@@ -3923,7 +3923,7 @@ bool nir_repair_ssa_impl(nir_function_impl *impl);
|
|||||||
bool nir_repair_ssa(nir_shader *shader);
|
bool nir_repair_ssa(nir_shader *shader);
|
||||||
|
|
||||||
void nir_convert_loop_to_lcssa(nir_loop *loop);
|
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
|
/* 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
|
* registers. If false, convert all values (even those not involved in a phi
|
||||||
|
@@ -48,6 +48,7 @@ typedef struct {
|
|||||||
|
|
||||||
/* Whether to skip loop invariant variables */
|
/* Whether to skip loop invariant variables */
|
||||||
bool skip_invariants;
|
bool skip_invariants;
|
||||||
|
bool skip_bool_invariants;
|
||||||
|
|
||||||
bool progress;
|
bool progress;
|
||||||
} lcssa_state;
|
} lcssa_state;
|
||||||
@@ -193,7 +194,8 @@ convert_loop_exit_for_ssa(nir_ssa_def *def, void *void_state)
|
|||||||
bool all_uses_inside_loop = true;
|
bool all_uses_inside_loop = true;
|
||||||
|
|
||||||
/* Don't create LCSSA-Phis for loop-invariant variables */
|
/* 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);
|
assert(def->parent_instr->pass_flags != undefined);
|
||||||
if (def->parent_instr->pass_flags == invariant)
|
if (def->parent_instr->pass_flags == invariant)
|
||||||
return true;
|
return true;
|
||||||
@@ -361,6 +363,7 @@ nir_convert_loop_to_lcssa(nir_loop *loop)
|
|||||||
state->loop = loop;
|
state->loop = loop;
|
||||||
state->shader = impl->function->shader;
|
state->shader = impl->function->shader;
|
||||||
state->skip_invariants = false;
|
state->skip_invariants = false;
|
||||||
|
state->skip_bool_invariants = false;
|
||||||
|
|
||||||
nir_foreach_block_in_cf_node (block, &loop->cf_node) {
|
nir_foreach_block_in_cf_node (block, &loop->cf_node) {
|
||||||
nir_foreach_instr(instr, block)
|
nir_foreach_instr(instr, block)
|
||||||
@@ -371,12 +374,13 @@ nir_convert_loop_to_lcssa(nir_loop *loop)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
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;
|
bool progress = false;
|
||||||
lcssa_state *state = rzalloc(NULL, lcssa_state);
|
lcssa_state *state = rzalloc(NULL, lcssa_state);
|
||||||
state->shader = shader;
|
state->shader = shader;
|
||||||
state->skip_invariants = skip_invariants;
|
state->skip_invariants = skip_invariants;
|
||||||
|
state->skip_bool_invariants = skip_bool_invariants;
|
||||||
|
|
||||||
nir_foreach_function(function, shader) {
|
nir_foreach_function(function, shader) {
|
||||||
if (function->impl == NULL)
|
if (function->impl == NULL)
|
||||||
|
Reference in New Issue
Block a user