[CPU] Handle NaN in fctidxx, fctiwxx.

This commit is contained in:
gibbed 2018-11-20 23:21:38 -06:00
parent 0206e90398
commit 22e7500f63
1 changed files with 22 additions and 2 deletions

View File

@ -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;
}