aco/isel: skip and(exec) for top level demote_if/terminate_if

In nested control flow this is nessecary to not demote/terminate invocations
that are part of the global but not part of the local mask.

At the top level, the masks are the same and no additional invocations
can be accidentally disabled.

Foz-DB Navi21:
Totals from 2095 (2.64% of 79395) affected shaders:
Instrs: 1058326 -> 1056839 (-0.14%)
CodeSize: 5632480 -> 5626616 (-0.10%)
Latency: 12082761 -> 12080520 (-0.02%); split: -0.02%, +0.00%
InvThroughput: 2246677 -> 2246636 (-0.00%); split: -0.00%, +0.00%
Copies: 114446 -> 114433 (-0.01%)
SALU: 230585 -> 229098 (-0.64%)

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32755>
This commit is contained in:
Georg Lehmann 2024-12-20 19:41:39 +01:00 committed by Marge Bot
parent 5b4b195f1b
commit 33a73203b0

View file

@ -8962,8 +8962,12 @@ visit_intrinsic(isel_context* ctx, nir_intrinsic_instr* instr)
if (instr->intrinsic == nir_intrinsic_demote_if) {
Temp src = get_ssa_temp(ctx, instr->src[0].ssa);
assert(src.regClass() == bld.lm);
cond =
bld.sop2(Builder::s_and, bld.def(bld.lm), bld.def(s1, scc), src, Operand(exec, bld.lm));
if (in_exec_divergent_or_in_loop(ctx)) {
cond = bld.sop2(Builder::s_and, bld.def(bld.lm), bld.def(s1, scc), src,
Operand(exec, bld.lm));
} else {
cond = Operand(src);
}
}
bld.pseudo(aco_opcode::p_demote_to_helper, cond);
@ -8989,8 +8993,12 @@ visit_intrinsic(isel_context* ctx, nir_intrinsic_instr* instr)
if (instr->intrinsic == nir_intrinsic_terminate_if) {
Temp src = get_ssa_temp(ctx, instr->src[0].ssa);
assert(src.regClass() == bld.lm);
cond =
bld.sop2(Builder::s_and, bld.def(bld.lm), bld.def(s1, scc), src, Operand(exec, bld.lm));
if (in_exec_divergent_or_in_loop(ctx)) {
cond = bld.sop2(Builder::s_and, bld.def(bld.lm), bld.def(s1, scc), src,
Operand(exec, bld.lm));
} else {
cond = Operand(src);
}
ctx->cf_info.had_divergent_discard |= nir_src_is_divergent(&instr->src[0]);
}