mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 22:19:02 +00:00
ppu: Improve FCTIW, FCTIWZ, FCTID and FCTIDZ
This commit is contained in:
parent
d48d424b19
commit
a560498cd4
2 changed files with 26 additions and 16 deletions
|
|
@ -4004,11 +4004,8 @@ void PPUTranslator::FRSP(ppu_opcode_t op)
|
|||
void PPUTranslator::FCTIW(ppu_opcode_t op)
|
||||
{
|
||||
const auto b = GetFpr(op.frb);
|
||||
//const auto sat_l = m_ir->CreateFCmpULT(b, ConstantFP::get(GetType<f64>(), -std::pow(2, 31))); // TODO ???
|
||||
//const auto sat_h = m_ir->CreateFCmpOGE(b, ConstantFP::get(GetType<f64>(), std::pow(2, 31)));
|
||||
//const auto converted = m_ir->CreateFPToSI(FP_SAT_OP(sat_l, b), GetType<s64>());
|
||||
//SetFpr(op.frd, m_ir->CreateSelect(sat_h, m_ir->getInt64(0x7fffffff), converted));
|
||||
SetFpr(op.frd, Call(GetType<s32>(), "llvm.x86.sse2.cvtsd2si", m_ir->CreateInsertElement(GetUndef<f64[2]>(), b, uint64_t{0})));
|
||||
SetFpr(op.frd, m_ir->CreateSelect(m_ir->CreateFCmpOGE(b, ConstantFP::get(GetType<f64>(), f64(INT32_MAX))), m_ir->getInt32(INT32_MAX),
|
||||
Call(GetType<s32>(), "llvm.x86.sse2.cvtsd2si", m_ir->CreateInsertElement(GetUndef<f64[2]>(), b, u64{0}))));
|
||||
|
||||
//SetFPSCR_FR(Call(GetType<bool>(), m_pure_attr, "__fctiw_get_fr", b));
|
||||
//SetFPSCR_FI(Call(GetType<bool>(), m_pure_attr, "__fctiw_get_fi", b));
|
||||
|
|
@ -4021,7 +4018,10 @@ void PPUTranslator::FCTIW(ppu_opcode_t op)
|
|||
void PPUTranslator::FCTIWZ(ppu_opcode_t op)
|
||||
{
|
||||
const auto b = GetFpr(op.frb);
|
||||
SetFpr(op.frd, Call(GetType<s32>(), "llvm.x86.sse2.cvttsd2si", m_ir->CreateInsertElement(GetUndef<f64[2]>(), b, uint64_t{0})));
|
||||
const auto xormask = m_ir->CreateSExt(m_ir->CreateFCmpOGE(b, ConstantFP::get(GetType<f64>(), std::exp2l(31.))), GetType<s32>());
|
||||
|
||||
// fix result saturation (0x80000000 -> 0x7fffffff)
|
||||
SetFpr(op.frd, m_ir->CreateXor(xormask, Call(GetType<s32>(), "llvm.x86.sse2.cvttsd2si", m_ir->CreateInsertElement(GetUndef<f64[2]>(), b, u64{0}))));
|
||||
}
|
||||
|
||||
void PPUTranslator::FDIV(ppu_opcode_t op)
|
||||
|
|
@ -4248,11 +4248,10 @@ void PPUTranslator::FABS(ppu_opcode_t op)
|
|||
void PPUTranslator::FCTID(ppu_opcode_t op)
|
||||
{
|
||||
const auto b = GetFpr(op.frb);
|
||||
//const auto sat_l = m_ir->CreateFCmpULT(b, ConstantFP::get(GetType<f64>(), -std::pow(2, 63)));
|
||||
//const auto sat_h = m_ir->CreateFCmpOGE(b, ConstantFP::get(GetType<f64>(), std::pow(2, 63)));
|
||||
//const auto converted = m_ir->CreateFPToSI(FP_SAT_OP(sat_l, b), GetType<s64>());
|
||||
//SetFpr(op.frd, m_ir->CreateSelect(sat_h, m_ir->getInt64(0x7fffffffffffffff), converted));
|
||||
SetFpr(op.frd, Call(GetType<s64>(), "llvm.x86.sse2.cvtsd2si64", m_ir->CreateInsertElement(GetUndef<f64[2]>(), b, uint64_t{0})));
|
||||
const auto xormask = m_ir->CreateSExt(m_ir->CreateFCmpOGE(b, ConstantFP::get(GetType<f64>(), std::exp2l(31.))), GetType<s64>());
|
||||
|
||||
// fix result saturation (0x8000000000000000 -> 0x7fffffffffffffff)
|
||||
SetFpr(op.frd, m_ir->CreateXor(xormask, Call(GetType<s64>(), "llvm.x86.sse2.cvtsd2si64", m_ir->CreateInsertElement(GetUndef<f64[2]>(), b, u64{0}))));
|
||||
|
||||
//SetFPSCR_FR(Call(GetType<bool>(), m_pure_attr, "__fctid_get_fr", b));
|
||||
//SetFPSCR_FI(Call(GetType<bool>(), m_pure_attr, "__fctid_get_fi", b));
|
||||
|
|
@ -4265,7 +4264,10 @@ void PPUTranslator::FCTID(ppu_opcode_t op)
|
|||
void PPUTranslator::FCTIDZ(ppu_opcode_t op)
|
||||
{
|
||||
const auto b = GetFpr(op.frb);
|
||||
SetFpr(op.frd, Call(GetType<s64>(), "llvm.x86.sse2.cvttsd2si64", m_ir->CreateInsertElement(GetUndef<f64[2]>(), b, uint64_t{0})));
|
||||
const auto xormask = m_ir->CreateSExt(m_ir->CreateFCmpOGE(b, ConstantFP::get(GetType<f64>(), std::exp2l(31.))), GetType<s64>());
|
||||
|
||||
// fix result saturation (0x8000000000000000 -> 0x7fffffffffffffff)
|
||||
SetFpr(op.frd, m_ir->CreateXor(xormask, Call(GetType<s64>(), "llvm.x86.sse2.cvttsd2si64", m_ir->CreateInsertElement(GetUndef<f64[2]>(), b, u64{0}))));
|
||||
}
|
||||
|
||||
void PPUTranslator::FCFID(ppu_opcode_t op)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue