From 2c43ea28f9d188c84460c2ebd34c505f8cc1ccd5 Mon Sep 17 00:00:00 2001 From: lzkk <956449176@qq.com> Date: Thu, 28 May 2026 19:40:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(mir):=20=E6=B5=AE=E7=82=B9=E6=AF=94?= =?UTF-8?q?=E8=BE=83=E8=A2=AB=E9=94=99=E8=AF=AF=E9=99=8D=E7=BA=A7=E4=B8=BA?= =?UTF-8?q?=E6=95=B4=E6=95=B0=E6=AF=94=E8=BE=83=E2=80=94=E2=80=9495=5Ffloa?= =?UTF-8?q?t=20=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EmitIntValue 中整数比较路径未检查浮点操作数,导致 fcmp olt 被降级为 fcvtzs+fcvtzs+cmp(整数比较),浮点语义损坏。 新增浮点操作数检测,走 FCmpRR+FCSet 路径。 门禁:functional 100/100, h_functional 40/40 --- src/mir/Lowering.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/mir/Lowering.cpp b/src/mir/Lowering.cpp index 28d65cb4..60f0af45 100644 --- a/src/mir/Lowering.cpp +++ b/src/mir/Lowering.cpp @@ -472,6 +472,23 @@ namespace mir { if (IsIntegerCompareOpcode(bin->GetOpcode())) { + // 浮点比较走 FCmpRR 路径(EmitCompareToFlags 定义在后,此处内联) + if (IsFloatValue(bin->GetLhs()) || IsFloatValue(bin->GetRhs())) + { + int flhs = EmitFloatValue(bin->GetLhs(), function, value_vregs, block); + int frhs = EmitFloatValue(bin->GetRhs(), function, value_vregs, block); + block.Append(Opcode::FCmpRR, + {Operand::VReg(flhs, VRegClass::Float), + Operand::VReg(frhs, VRegClass::Float)}); + CondCode cond = GetCondCodeForCompareOpcode(bin->GetOpcode()); + int dst = function.CreateVReg(VRegClass::Int); + block.Append(Opcode::CSet, + {Operand::VReg(dst, VRegClass::Int), + Operand::Imm(static_cast(cond))}); + value_vregs[value] = dst; + return dst; + } + int lhs = EmitIntValue(bin->GetLhs(), function, value_vregs, scalar_slots, array_slots, block); int rhs = EmitIntValue(bin->GetRhs(), function, value_vregs,