nir/opt_if: run opt_peel_loop_initial_if after all other optimizations

Fixes dEQP-VK.graphicsfuzz.loops-ifs-continues-call with RADV.

opt_if_loop_terminator can cause this optimization or
opt_if_simplification to be run on the non-SSA code.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Fixes: 52c8bc0130 ('nir: make opt_if_loop_terminator() less strict')
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2943
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4757>
This commit is contained in:
Rhys Perry
2020-05-12 11:10:18 +01:00
committed by Marge Bot
parent d221f70299
commit 50bead32b1
7 changed files with 44 additions and 17 deletions

View File

@@ -11,9 +11,6 @@ dEQP-VK.glsl.builtin.precision.asin.highp.vec4
# CTS bug (list of extensions not up-to-date).
dEQP-VK.info.device_extensions
# ACO specific issues.
dEQP-VK.graphicsfuzz.loops-ifs-continues-call
# Interesting failures...
dEQP-VK.renderpass2.depth_stencil_resolve.image_2d_16_64_6.samples_2.d32_sfloat_s8_uint.stencil_max
dEQP-VK.renderpass2.depth_stencil_resolve.image_2d_16_64_6.samples_2.d32_sfloat_s8_uint.stencil_min

View File

@@ -10,4 +10,3 @@ dEQP-VK.info.device_extensions
# ACO specific issues.
dEQP-VK.transform_feedback.simple.multistreams_1
dEQP-VK.transform_feedback.simple.multistreams_3
dEQP-VK.graphicsfuzz.loops-ifs-continues-call

View File

@@ -6,6 +6,3 @@ dEQP-VK.glsl.builtin.precision.asin.highp.vec4
# CTS bug (list of extensions not up-to-date).
dEQP-VK.info.device_extensions
# ACO specific issues.
dEQP-VK.graphicsfuzz.loops-ifs-continues-call

View File

@@ -10,6 +10,3 @@ dEQP-VK.glsl.builtin.precision.asin.highp.vec4
# CTS bug (list of extensions not up-to-date).
dEQP-VK.info.device_extensions
# ACO specific issues.
dEQP-VK.graphicsfuzz.loops-ifs-continues-call

View File

@@ -10,4 +10,3 @@ dEQP-VK.info.device_extensions
# ACO specific issues.
dEQP-VK.transform_feedback.simple.multistreams_1
dEQP-VK.transform_feedback.simple.multistreams_3
dEQP-VK.graphicsfuzz.loops-ifs-continues-call

View File

@@ -10,4 +10,3 @@ dEQP-VK.info.device_extensions
# ACO specific issues.
dEQP-VK.transform_feedback.simple.multistreams_1
dEQP-VK.transform_feedback.simple.multistreams_3
dEQP-VK.graphicsfuzz.loops-ifs-continues-call

View File

@@ -1334,7 +1334,6 @@ opt_if_cf_list(nir_builder *b, struct exec_list *cf_list,
progress |= opt_if_cf_list(b, &loop->body,
aggressive_last_continue);
progress |= opt_simplify_bcsel_of_phi(b, loop);
progress |= opt_peel_loop_initial_if(loop);
progress |= opt_if_loop_last_continue(loop,
aggressive_last_continue);
break;
@@ -1348,6 +1347,37 @@ opt_if_cf_list(nir_builder *b, struct exec_list *cf_list,
return progress;
}
static bool
opt_peel_loop_initial_if_cf_list(struct exec_list *cf_list)
{
bool progress = false;
foreach_list_typed(nir_cf_node, cf_node, node, cf_list) {
switch (cf_node->type) {
case nir_cf_node_block:
break;
case nir_cf_node_if: {
nir_if *nif = nir_cf_node_as_if(cf_node);
progress |= opt_peel_loop_initial_if_cf_list(&nif->then_list);
progress |= opt_peel_loop_initial_if_cf_list(&nif->else_list);
break;
}
case nir_cf_node_loop: {
nir_loop *loop = nir_cf_node_as_loop(cf_node);
progress |= opt_peel_loop_initial_if_cf_list(&loop->body);
progress |= opt_peel_loop_initial_if(loop);
break;
}
case nir_cf_node_function:
unreachable("Invalid cf type");
}
}
return progress;
}
/**
* These optimisations depend on nir_metadata_block_index and therefore must
* not do anything to cause the metadata to become invalid.
@@ -1402,17 +1432,26 @@ nir_opt_if(nir_shader *shader, bool aggressive_last_continue)
nir_metadata_preserve(function->impl, nir_metadata_block_index |
nir_metadata_dominance);
if (opt_if_cf_list(&b, &function->impl->body,
aggressive_last_continue)) {
nir_metadata_preserve(function->impl, nir_metadata_none);
bool preserve = true;
if (opt_if_cf_list(&b, &function->impl->body, aggressive_last_continue)) {
preserve = false;
progress = true;
}
if (opt_peel_loop_initial_if_cf_list(&function->impl->body)) {
preserve = false;
progress = true;
/* If that made progress, we're no longer really in SSA form. We
* need to convert registers back into SSA defs and clean up SSA defs
* that don't dominate their uses.
*/
nir_lower_regs_to_ssa_impl(function->impl);
}
progress = true;
if (preserve) {
nir_metadata_preserve(function->impl, nir_metadata_none);
} else {
#ifndef NDEBUG
function->impl->valid_metadata &= ~nir_metadata_not_properly_reset;