aco: don't DCE atomics with return values

We don't create atomics with definitions if they are not used in NIR, but
our own DCE can remove the uses if an export turns out to be null.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Fixes: 93c8ebfa78 ('aco: Initial commit of independent AMD compiler')
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3081>
This commit is contained in:
Rhys Perry
2019-12-16 13:30:10 +00:00
parent 8f291dc146
commit 69bed1c918
5 changed files with 26 additions and 19 deletions
+1 -6
View File
@@ -2265,12 +2265,7 @@ void select_instruction(opt_ctx &ctx, aco_ptr<Instruction>& instr)
{
const uint32_t threshold = 4;
/* Dead Code Elimination:
* We remove instructions if they define temporaries which all are unused */
const bool is_used = instr->definitions.empty() ||
std::any_of(instr->definitions.begin(), instr->definitions.end(),
[&ctx](const Definition& def) { return ctx.uses[def.tempId()]; });
if (!is_used) {
if (is_dead(ctx.uses, instr.get())) {
instr.reset();
return;
}