emit_x64: Use xorps/xorpd when argument to TransferToFP32/TransferToFP64 is an immediate zero

This commit is contained in:
MerryMage 2016-12-03 11:36:03 +00:00
parent e166965f3e
commit cede5e442a

View file

@ -1677,17 +1677,27 @@ void EmitX64::EmitTransferFromFP64(IR::Block& block, IR::Inst* inst) {
} }
void EmitX64::EmitTransferToFP32(IR::Block& block, IR::Inst* inst) { void EmitX64::EmitTransferToFP32(IR::Block& block, IR::Inst* inst) {
Xbyak::Xmm result = reg_alloc.DefXmm(inst); if (inst->GetArg(0).IsImmediate() && inst->GetArg(0).GetU32() == 0) {
Xbyak::Reg32 source = reg_alloc.UseGpr(inst->GetArg(0)).cvt32(); Xbyak::Xmm result = reg_alloc.DefXmm(inst);
// TODO: Eliminate this. code->xorps(result, result);
code->movd(result, source); } else {
Xbyak::Xmm result = reg_alloc.DefXmm(inst);
Xbyak::Reg32 source = reg_alloc.UseGpr(inst->GetArg(0)).cvt32();
// TODO: Eliminate this.
code->movd(result, source);
}
} }
void EmitX64::EmitTransferToFP64(IR::Block& block, IR::Inst* inst) { void EmitX64::EmitTransferToFP64(IR::Block& block, IR::Inst* inst) {
Xbyak::Xmm result = reg_alloc.DefXmm(inst); if (inst->GetArg(0).IsImmediate() && inst->GetArg(0).GetU64() == 0) {
Xbyak::Reg64 source = reg_alloc.UseGpr(inst->GetArg(0)); Xbyak::Xmm result = reg_alloc.DefXmm(inst);
// TODO: Eliminate this. code->xorpd(result, result);
code->movq(result, source); } else {
Xbyak::Xmm result = reg_alloc.DefXmm(inst);
Xbyak::Reg64 source = reg_alloc.UseGpr(inst->GetArg(0));
// TODO: Eliminate this.
code->movq(result, source);
}
} }
void EmitX64::EmitFPAbs32(IR::Block&, IR::Inst* inst) { void EmitX64::EmitFPAbs32(IR::Block&, IR::Inst* inst) {