nir/opt_if: Don't split ALU for single block infinite loops

Some infinite loop cases were already covered by other
restrictions (e.g. if the loop had a body), but the case with a single
block in the loop body wasn't yet.

This prevents an infinite loop when optimizing the shader in
dEQP-VK.reconvergence.subgroup_uniform_control_flow_ballot.compute.nesting2.3.2
and various others reconvergence tests.

Fixes: 0881e90c09 ("nir: Split ALU instructions in loops that read phis")
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> [v1]
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11476>
This commit is contained in:
Caio Marcelo de Oliveira Filho
2021-06-18 12:24:11 -07:00
committed by Marge Bot
parent 7b89e4d104
commit b951929795

View File

@@ -408,6 +408,10 @@ opt_split_alu_of_phi(nir_builder *b, nir_loop *loop)
if (header_block->predecessors->entries != 2)
return false;
nir_block *continue_block = find_continue_block(loop);
if (continue_block == header_block)
return false;
nir_foreach_instr_safe(instr, header_block) {
if (instr->type != nir_instr_type_alu)
continue;
@@ -499,8 +503,6 @@ opt_split_alu_of_phi(nir_builder *b, nir_loop *loop)
}
/* Split ALU of Phi */
nir_block *const continue_block = find_continue_block(loop);
b->cursor = nir_after_block(prev_block);
nir_ssa_def *prev_value = clone_alu_and_replace_src_defs(b, alu, prev_srcs);
@@ -683,7 +685,7 @@ opt_simplify_bcsel_of_phi(nir_builder *b, nir_loop *loop)
* continue_block from the other bcsel source. Both sources have
* already been verified to be phi nodes.
*/
nir_block *const continue_block = find_continue_block(loop);
nir_block *continue_block = find_continue_block(loop);
nir_phi_instr *const phi = nir_phi_instr_create(b->shader);
nir_phi_src *phi_src;