Skip to contentSkip to conversation

target/i386: Don't clear C1 for FCOMI/FCOMIP/FUCOMI/FUCOMIP

PATCH Applied Simon Scherer 2 participants 2 messages Sep 11 – Sep 16

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/i386: Don't clear C1 for FCOMI/FCOMIP/FUCOMI/FUCOMIP

Commit 6802a4b23919 ("target/i386: clear C1 for all x87 compare instructions") added an unconditional C1 clear to helper_fcomi_ST0_FT0() and helper_fucomi_ST0_FT0(), based on the SDM listing "C1 Set to 0" under FPU Flags Affected for FCOMI/FCOMIP/FUCOMI/FUCOMIP.

Testing on real x86-64 Intel and AMD hardware shows these instructions leave C1 unchanged, unlike FCOM/FUCOM/FICOM. The SDM text appears to have been carried over from the FCOM/FUCOM description.

Revert that part of the commit. The FCOM/FUCOM/FICOM changes are kept.

Fixes 6802a4b23919 ("target/i386: clear C1 for all x87 compare instructions")

---
This was caught before 6802a4b23919 landed. V3 [1] dropped the fcomi/fucomi changes, but v2 was the version applied

[1] https://patchew.org/QEMU/[email protected]/

 target/i386/tcg/fpu_helper.c | 4 ----
 1 file changed, 4 deletions(-)
target/i386/tcg/fpu_helper.c +0 -4
index 54ff4fe31313..56d093da8c9a 100644
@@ -565,8 +565,6 @@ void helper_fcomi_ST0_FT0(CPUX86State *env)
     /* OF, SF, and AF are unconditionally cleared to 0 */
     CC_SRC = fcomi_ccval[ret + 1];
     CC_OP = CC_OP_EFLAGS;
-    /* C1 is unconditionally cleared to 0 */
-    env->fpus &= ~0x0200;
     merge_exception_flags(env, old_flags);
 }
 
@@ -579,8 +577,6 @@ void helper_fucomi_ST0_FT0(CPUX86State *env)
     /* OF, SF, and AF are unconditionally cleared to 0 */
     CC_SRC = fcomi_ccval[ret + 1];
     CC_OP = CC_OP_EFLAGS;
-    /* C1 is unconditionally cleared to 0 */
-    env->fpus &= ~0x0200;
     merge_exception_flags(env, old_flags);
 }
 
Signature · 1 line
2.53.0