From 83228a81235a2286129074b4378edfed0533e446 Mon Sep 17 00:00:00 2001 From: lzkk <956449176@qq.com> Date: Wed, 27 May 2026 16:24:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(mir):=20GPR32/GPR64=E5=88=AB=E5=90=8D?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E7=A7=BB=E9=99=A4segments.empty()=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wn和Xn是同一硬件寄存器(如W12和X12),GPR32和GPR64 vreg 在同一phys_reg上总是冲突,无论segments是否为空。 原代码要求!segments.empty(),导致某些情况下别名冲突被漏检。 参考: AArch64寄存器别名机制,Wn为Xn的低32位 --- src/mir/GreedyAlloc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mir/GreedyAlloc.cpp b/src/mir/GreedyAlloc.cpp index 491d5c7e..803c9e38 100644 --- a/src/mir/GreedyAlloc.cpp +++ b/src/mir/GreedyAlloc.cpp @@ -482,7 +482,7 @@ bool LiveRegMatrix::CheckInterference(const LiveInterval &li, int phys_reg) cons bool gpr32_64_alias = (li.reg_class == RegClass::GPR32 && other->reg_class == RegClass::GPR64) || (li.reg_class == RegClass::GPR64 && other->reg_class == RegClass::GPR32); - if (gpr32_64_alias && !li.segments.empty() && !other->segments.empty()) + if (gpr32_64_alias) return true; for (auto &sa : li.segments) for (auto &sb : other->segments) @@ -501,7 +501,7 @@ LiveInterval *LiveRegMatrix::GetConflict(const LiveInterval &li, bool gpr32_64_alias = (li.reg_class == RegClass::GPR32 && other->reg_class == RegClass::GPR64) || (li.reg_class == RegClass::GPR64 && other->reg_class == RegClass::GPR32); - if (gpr32_64_alias && !li.segments.empty() && !other->segments.empty()) + if (gpr32_64_alias) return other; for (auto &sa : li.segments) for (auto &sb : other->segments)