Repository navigation
x87: compares aborted by an unmasked invalid-operand exception, and C1 after a compare #8877
Unanswered
Technologov
asked this question in
Issue verification
Replies: 1 comment
|
I would really compare this against real Pentium etc. CPU's because we have no idea how much the behavior has changed. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Checklist
What happened?
x87: compares aborted by an unmasked invalid-operand exception, and C1 after a compare
Five commits (0001-0005), both x87 cores, every result measured on four CPUs - AMD Zen 4 (Ryzen 7 7700), AMD Zen 2 (Threadripper 3990X), Intel Haswell-EP (Xeon E5-1650 v3) and Intel Raptor Lake (Core i5-13500), under KVM with -cpu pentium2 - which all agree on every case below.
An aborted compare still writes the unordered result. When FCOM / FUCOM / FICOM or FCOMI / FUCOMI raise an invalid-operand exception with #IA unmasked (CW = 0340h) - an SNaN or unsupported operand, or an empty register - 86Box currently leaves C3 C2 C0, or EFLAGS, as they were. All four CPUs write the unordered result anyway: C3 = C2 = C0 = 1, or ZF = PF = CF = 1 with OF = SF = AF = 0 (EFLAGS 047h from both 002h and 8D7h). The popping forms do not pop, which 86Box already gets right. FTST already writes its result this way ("unordered for a NaN, #IA masked or not"); this makes the other compares match it.
softfloat x87: FCOM, FUCOM and FICOM write C3 C2 C0 when #IA is unmasked
softfloat x87: FCOMI, FCOMIP, FUCOMI and FUCOMIP write EFLAGS when #IA is unmasked
x87: a compare from an empty register writes the unordered result when #IA is unmasked (the host x87's stack-fault path, x87_stack_underflow_compare() and X87_CHECK_UNDERFLOW_COMI)
C1. The FCOM family clears C1; the FCOMI family leaves it alone (only a stack fault clears it). The softfloat core cleared C1 in FCOMI too, and the host x87 left it set in FCOM / FUCOM / FICOM / FTST.
softfloat x87: FCOMI, FCOMIP, FUCOMI and FUCOMIP leave C1 unchanged
x87: FCOM, FUCOM, FICOM and FTST clear C1
Tested with our level-4 CPU test image on a KN97 + Pentium II 233 (interpreter and new recompiler, softfloat and host x87): divergences from the four CPUs in X87_ARITH 127 -> 5 and in X87_EXC 29 -> 4 with softfloat, X87_EXC 96 -> 89 with the host x87 (the rest of the host x87's are its 53-bit precision); interpreter and recompiler give identical records, and no other section changes. What remains in these two sections is FSCALE with an unmasked overflow that is still out of range, and FPATAN setting DE for a denormal result (PR 4).
Not covered here (host x87): with an SNaN operand and #IA unmasked, FCOMP and FCOMIP still pop (silicon: no pop). The host core compares doubles, so its SNaN handling is left out of this PR.
0001-softfloat-x87-FCOM-FUCOM-and-FICOM-write-C3-C2-C0-wh.patch
0002-softfloat-x87-FCOMI-FCOMIP-FUCOMI-and-FUCOMIP-write-.patch
0003-softfloat-x87-FCOMI-FCOMIP-FUCOMI-and-FUCOMIP-leave-.patch
0004-x87-a-compare-from-an-empty-register-writes-the-unor.patch
0005-x87-FCOM-FUCOM-FICOM-and-FTST-clear-C1.patch
Configuration file
Operating system
Linux
86Box version
master f93598b
Build architecture
Linux - x64 (64-bit)
Build type
Additional context
No response
All reactions