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,