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:
@@ -57,11 +57,7 @@ void process_block(dce_ctx& ctx, Block& block)
|
||||
continue;
|
||||
|
||||
aco_ptr<Instruction>& instr = block.instructions[idx];
|
||||
const bool is_live = instr->definitions.empty() ||
|
||||
std::any_of(instr->definitions.begin(), instr->definitions.end(),
|
||||
[&ctx] (const Definition& def) { return !def.isTemp() || ctx.uses[def.tempId()];});
|
||||
|
||||
if (is_live) {
|
||||
if (!is_dead(ctx.uses, instr.get())) {
|
||||
for (const Operand& op : instr->operands) {
|
||||
if (op.isTemp()) {
|
||||
if (ctx.uses[op.tempId()] == 0)
|
||||
@@ -81,6 +77,16 @@ void process_block(dce_ctx& ctx, Block& block)
|
||||
|
||||
} /* end namespace */
|
||||
|
||||
bool is_dead(const std::vector<uint16_t>& uses, Instruction *instr)
|
||||
{
|
||||
if (instr->definitions.empty())
|
||||
return false;
|
||||
if (std::any_of(instr->definitions.begin(), instr->definitions.end(),
|
||||
[&uses] (const Definition& def) { return uses[def.tempId()];}))
|
||||
return false;
|
||||
return instr_info.is_atomic[(int)instr->opcode];
|
||||
}
|
||||
|
||||
std::vector<uint16_t> dead_code_analysis(Program *program) {
|
||||
|
||||
dce_ctx ctx(program);
|
||||
|
||||
Reference in New Issue
Block a user