Skip to content

x87: Fix FPREM/FPREM1 semantics in dynarec and interpreter#3505

Merged
ptitSeb merged 1 commit intoptitSeb:mainfrom
yzewei:x87_fprem/1
Feb 13, 2026
Merged

x87: Fix FPREM/FPREM1 semantics in dynarec and interpreter#3505
ptitSeb merged 1 commit intoptitSeb:mainfrom
yzewei:x87_fprem/1

Conversation

@yzewei
Copy link
Contributor

@yzewei yzewei commented Feb 13, 2026

FPREM is now calculated using fmod, and the lower-order quotient is calculated using trunc(x/y) to write back the condition code bits (C0/C1/C2/C3).

FPREM1 is now calculated using remquo, ensuring that the remainder matches the lower 3 condition code bits of the quotient.

Special inputs such as NaN/Inf/division by zero are handled separately, and abnormal behavior is aligned with the x87 expected flag.

Signed-off-by: Zewei Yang <yangzewei@loongson.cn>
@ptitSeb
Copy link
Owner

ptitSeb commented Feb 13, 2026

Can you check your changes with games llike Flatout / Flatout 2 ?
On what program/games did you check this PR?

@yzewei
Copy link
Contributor Author

yzewei commented Feb 13, 2026

Can you check your changes with games llike Flatout / Flatout 2 ? On what program/games did you check this PR?

I discovered this while running NumPy's official test cases test_float_remainder_errors and test_float_remainder_overflow. I don't have the game environment running here.

@yzewei
Copy link
Contributor Author

yzewei commented Feb 13, 2026

Can you check your changes with games llike Flatout / Flatout 2 ? On what program/games did you check this PR?

However, it is certain that this problem can be reproduced.

@ptitSeb
Copy link
Owner

ptitSeb commented Feb 13, 2026

Ok, I'll check later, and roll back the change if I notice regressions (this opcode is sensitive)

@ptitSeb ptitSeb merged commit a0b962c into ptitSeb:main Feb 13, 2026
27 checks passed
@yzewei
Copy link
Contributor Author

yzewei commented Feb 13, 2026

Ok, I'll check later, and roll back the change if I notice regressions (this opcode is sensitive)

No problem, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants