From 1d0a12438dc6614666a6b863516db585e39e8bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 23 Jul 2024 15:54:01 +0200 Subject: [PATCH] aco/cssa: short-cut some trivial case If a phi-operand is not flagged as kill, it cannot be coalesced because it interferes with the live-out variable. Also do the regClass check earlier. Part-of: --- src/amd/compiler/aco_lower_to_cssa.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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()};