emit_x64_floating_point: Correct use of UseGpr() in EmitFPU32ToDouble() and EmitFPU32ToSingle()
In the non-AVX512 path, the following code is present: code.mov(from.cvt32(), from.cvt32()); since this potentially modifies 'from', we should be using UseScratchGpr() instead.
This commit is contained in:
parent
fbd7623fe5
commit
7252293184
1 changed files with 4 additions and 2 deletions
|
@ -1032,15 +1032,16 @@ void EmitX64::EmitFPS32ToSingle(EmitContext& ctx, IR::Inst* inst) {
|
||||||
void EmitX64::EmitFPU32ToSingle(EmitContext& ctx, IR::Inst* inst) {
|
void EmitX64::EmitFPU32ToSingle(EmitContext& ctx, IR::Inst* inst) {
|
||||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||||
|
|
||||||
const Xbyak::Reg64 from = ctx.reg_alloc.UseGpr(args[0]);
|
|
||||||
const Xbyak::Xmm to = ctx.reg_alloc.ScratchXmm();
|
const Xbyak::Xmm to = ctx.reg_alloc.ScratchXmm();
|
||||||
const bool round_to_nearest = args[1].GetImmediateU1();
|
const bool round_to_nearest = args[1].GetImmediateU1();
|
||||||
ASSERT_MSG(!round_to_nearest, "round_to_nearest unimplemented");
|
ASSERT_MSG(!round_to_nearest, "round_to_nearest unimplemented");
|
||||||
|
|
||||||
if (code.DoesCpuSupport(Xbyak::util::Cpu::tAVX512F)) {
|
if (code.DoesCpuSupport(Xbyak::util::Cpu::tAVX512F)) {
|
||||||
|
const Xbyak::Reg64 from = ctx.reg_alloc.UseGpr(args[0]);
|
||||||
code.vcvtusi2ss(to, to, from.cvt32());
|
code.vcvtusi2ss(to, to, from.cvt32());
|
||||||
} else {
|
} else {
|
||||||
// We are using a 64-bit GPR register to ensure we don't end up treating the input as signed
|
// We are using a 64-bit GPR register to ensure we don't end up treating the input as signed
|
||||||
|
const Xbyak::Reg64 from = ctx.reg_alloc.UseScratchGpr(args[0]);
|
||||||
code.mov(from.cvt32(), from.cvt32()); // TODO: Verify if this is necessary
|
code.mov(from.cvt32(), from.cvt32()); // TODO: Verify if this is necessary
|
||||||
code.cvtsi2ss(to, from);
|
code.cvtsi2ss(to, from);
|
||||||
}
|
}
|
||||||
|
@ -1076,15 +1077,16 @@ void EmitX64::EmitFPS64ToDouble(EmitContext& ctx, IR::Inst* inst) {
|
||||||
void EmitX64::EmitFPU32ToDouble(EmitContext& ctx, IR::Inst* inst) {
|
void EmitX64::EmitFPU32ToDouble(EmitContext& ctx, IR::Inst* inst) {
|
||||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||||
|
|
||||||
const Xbyak::Reg64 from = ctx.reg_alloc.UseGpr(args[0]);
|
|
||||||
const Xbyak::Xmm to = ctx.reg_alloc.ScratchXmm();
|
const Xbyak::Xmm to = ctx.reg_alloc.ScratchXmm();
|
||||||
const bool round_to_nearest = args[1].GetImmediateU1();
|
const bool round_to_nearest = args[1].GetImmediateU1();
|
||||||
ASSERT_MSG(!round_to_nearest, "round_to_nearest unimplemented");
|
ASSERT_MSG(!round_to_nearest, "round_to_nearest unimplemented");
|
||||||
|
|
||||||
if (code.DoesCpuSupport(Xbyak::util::Cpu::tAVX512F)) {
|
if (code.DoesCpuSupport(Xbyak::util::Cpu::tAVX512F)) {
|
||||||
|
const Xbyak::Reg64 from = ctx.reg_alloc.UseGpr(args[0]);
|
||||||
code.vcvtusi2sd(to, to, from.cvt32());
|
code.vcvtusi2sd(to, to, from.cvt32());
|
||||||
} else {
|
} else {
|
||||||
// We are using a 64-bit GPR register to ensure we don't end up treating the input as signed
|
// We are using a 64-bit GPR register to ensure we don't end up treating the input as signed
|
||||||
|
const Xbyak::Reg64 from = ctx.reg_alloc.UseScratchGpr(args[0]);
|
||||||
code.mov(from.cvt32(), from.cvt32()); // TODO: Verify if this is necessary
|
code.mov(from.cvt32(), from.cvt32()); // TODO: Verify if this is necessary
|
||||||
code.cvtsi2sd(to, from);
|
code.cvtsi2sd(to, from);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue