fix(mir): 浮点比较被错误降级为整数比较——95_float 修复

EmitIntValue 中整数比较路径未检查浮点操作数,导致 fcmp olt
被降级为 fcvtzs+fcvtzs+cmp(整数比较),浮点语义损坏。
新增浮点操作数检测,走 FCmpRR+FCSet 路径。

门禁:functional 100/100, h_functional 40/40
lzk
lzkk 2 days ago
parent ec8c874829
commit 2c43ea28f9

@ -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<int>(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,

Loading…
Cancel
Save