aco/insert_exec: only restore wqm mask after control flow if necessary

The next commit will make this not free, so we should avoid it if possible.

Foz-DB Navi31:
Totals from 3933 (4.93% of 79789) affected shaders:
Instrs: 5726914 -> 5727295 (+0.01%); split: -0.00%, +0.01%
CodeSize: 31307100 -> 31308884 (+0.01%); split: -0.00%, +0.01%
SpillSGPRs: 1797 -> 1793 (-0.22%); split: -0.33%, +0.11%
Latency: 58973929 -> 58974343 (+0.00%); split: -0.00%, +0.00%
InvThroughput: 8591893 -> 8591911 (+0.00%); split: -0.00%, +0.00%
SClause: 209074 -> 209115 (+0.02%); split: -0.00%, +0.02%
Copies: 423965 -> 432420 (+1.99%)
Branches: 149976 -> 149979 (+0.00%); split: -0.00%, +0.00%
PreSGPRs: 200175 -> 200663 (+0.24%)
VALU: 3440165 -> 3440156 (-0.00%); split: -0.00%, +0.00%
SALU: 555727 -> 556143 (+0.07%); split: -0.00%, +0.08%

Fixes: b872ff6ef2 ("aco/insert_exec_mask: if applicable, use s_wqm to restore exec after divergent CF")
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34659>
(cherry picked from commit 13f6be262a47439389b0d290839109c47d1d3271)
This commit is contained in:
Georg Lehmann
2025-04-22 19:42:02 +02:00
committed by Eric Engestrom
parent 461f11239e
commit 4fb4880183
2 changed files with 10 additions and 3 deletions

View File

@@ -14,7 +14,7 @@
"description": "aco/insert_exec: only restore wqm mask after control flow if necessary",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "b872ff6ef28bc44ac0f7aa5f963a273e40c79a61",
"notes": null

View File

@@ -54,6 +54,7 @@ struct exec_ctx {
std::vector<block_info> info;
std::vector<loop_info> loop;
bool handle_wqm = false;
bool had_demote_in_cf = false;
exec_ctx(Program* program_) : program(program_), info(program->blocks.size()) {}
};
@@ -370,11 +371,15 @@ add_coupling_code(exec_ctx& ctx, Block* block, std::vector<aco_ptr<Instruction>>
ctx.handle_wqm = false;
restore_exec = false;
i++;
} else if (restore_exec && ctx.info[idx].exec[1].type & mask_type_global) {
/* Use s_wqm to restore exec after divergent CF in order to disable dead quads. */
} else if (restore_exec && ctx.info[idx].exec[1].type & mask_type_global &&
ctx.had_demote_in_cf) {
/* Use s_wqm to restore exec after demote in divergent CF in order to disable dead
* quads.
*/
bld.sop1(Builder::s_wqm, Definition(exec, bld.lm), bld.def(s1, scc),
ctx.info[idx].exec[0].op);
restore_exec = false;
ctx.had_demote_in_cf = false;
}
}
}
@@ -546,6 +551,8 @@ process_instructions(exec_ctx& ctx, Block* block, std::vector<aco_ptr<Instructio
bld.sop2(Builder::s_cselect, Definition(exec, bld.lm), Operand(exec, bld.lm),
Operand::zero(bld.lm.bytes()), bld.scc(cond));
exit_cond = Operand(cond, scc);
/* Remember to disable empty quads in top level control flow. */
ctx.had_demote_in_cf = true;
}
}