diff --git a/src/xenia/cpu/ppc/ppc_emit_fpu.cc b/src/xenia/cpu/ppc/ppc_emit_fpu.cc index 24f2cd732..1aadfa82f 100644 --- a/src/xenia/cpu/ppc/ppc_emit_fpu.cc +++ b/src/xenia/cpu/ppc/ppc_emit_fpu.cc @@ -242,10 +242,20 @@ int InstrEmit_fcfidx(PPCHIRBuilder& f, const InstrData& i) { int InstrEmit_fctidxx_(PPCHIRBuilder& f, const InstrData& i, RoundMode round_mode) { - Value* v = f.Convert(f.LoadFPR(i.X.RB), INT64_TYPE, round_mode); + auto end = f.NewLabel(); + auto isnan = f.NewLabel(); + Value* v; + f.BranchTrue(f.IsNan(f.LoadFPR(i.X.RB)), isnan); + v = f.Convert(f.LoadFPR(i.X.RB), INT64_TYPE, round_mode); v = f.Cast(v, FLOAT64_TYPE); f.StoreFPR(i.X.RT, v); f.UpdateFPSCR(v, i.X.Rc); + f.Branch(end); + f.MarkLabel(isnan); + v = f.Cast(f.LoadConstantUint64(0x8000000000000000u), FLOAT64_TYPE); + f.StoreFPR(i.X.RT, v); + f.UpdateFPSCR(v, i.X.Rc); + f.MarkLabel(end); return 0; } @@ -260,10 +270,20 @@ int InstrEmit_fctidzx(PPCHIRBuilder& f, const InstrData& i) { int InstrEmit_fctiwxx_(PPCHIRBuilder& f, const InstrData& i, RoundMode round_mode) { - Value* v = f.Convert(f.LoadFPR(i.X.RB), INT32_TYPE, round_mode); + auto end = f.NewLabel(); + auto isnan = f.NewLabel(); + Value* v; + f.BranchTrue(f.IsNan(f.LoadFPR(i.X.RB)), isnan); + v = f.Convert(f.LoadFPR(i.X.RB), INT32_TYPE, round_mode); v = f.Cast(f.SignExtend(v, INT64_TYPE), FLOAT64_TYPE); f.StoreFPR(i.X.RT, v); f.UpdateFPSCR(v, i.X.Rc); + f.Branch(end); + f.MarkLabel(isnan); + v = f.Cast(f.LoadConstantUint32(0x80000000u), FLOAT64_TYPE); + f.StoreFPR(i.X.RT, v); + f.UpdateFPSCR(v, i.X.Rc); + f.MarkLabel(end); return 0; }