diff --git a/src/amd/compiler/aco_lower_to_cssa.cpp b/src/amd/compiler/aco_lower_to_cssa.cpp index b783295fad9..a25eee2b841 100644 --- a/src/amd/compiler/aco_lower_to_cssa.cpp +++ b/src/amd/compiler/aco_lower_to_cssa.cpp @@ -328,7 +328,11 @@ bool try_coalesce_copy(cssa_ctx& ctx, copy copy, uint32_t block_idx) { /* we can only coalesce temporaries */ - if (!copy.op.isTemp()) + if (!copy.op.isTemp() || !copy.op.isKill()) + return false; + + /* we can only coalesce copies of the same register class */ + if (copy.op.regClass() != copy.def.regClass()) return false; /* try emplace a merge_node for the copy operand */ @@ -343,10 +347,6 @@ try_coalesce_copy(cssa_ctx& ctx, copy copy, uint32_t block_idx) op_node.value = copy.op; } - /* we can only coalesce copies of the same register class */ - if (copy.op.regClass() != copy.def.regClass()) - return false; - /* check if this operand has not yet been coalesced */ if (op_node.index == -1u) { merge_set op_set = merge_set{copy.op.getTemp()};