Instruction
FUCOM
Compares ST(0) with ST(i) and sets C0, C2 and C3 of the x87 status word; only a signaling NaN is an invalid operation.
- Extensions
- Forms
- 1 (1 Legacy)
- Data
- Intel XED v2026.08.23
FUCOM compares ST(0) with ST(i), or with ST(1) when no register is named, and sets C0, C2 and C3 of the x87 status word the way FCOM does: all clear for greater, C0 for less, C3 for equal (-0 equals +0), all three for unordered; C1 is cleared. FCOM’s page has the table and how the codes reach RFLAGS. The U stands for unordered: a quiet NaN gives unordered without the invalid-operation exception (IE), which FCOM raises for any NaN. FUCOM has no memory form. FUCOMP pops once after the compare, and FUCOMPP, which compares ST(0) with ST(1), pops twice. Intel’s manual dates the three to the Intel 387; from the P6 family on, FUCOMI writes RFLAGS directly.
Without FUCOMI
GCC 14 and Clang 23 at -O2 with -m32 -march=i386 compile a compare
of two doubles to two FLDs, a compare and FNSTSW AX:
a == b: GCC uses FUCOMPP, thenand ah, 69andcmp ah, 64, since C3 alone means equal and C3 with C2 and C0 means unordered. Clang uses FUCOMPP and SAHF, which puts C0, C2 and C3 in CF, PF and ZF, then SETE and SETNP.a < b: GCC uses the signaling FCOMP, as C’s relational operators ask, and keeps FUCOMPP forisless(a, b). Clang uses FUCOMPP and SETA for both, so itsa < braises no IE for a QNaN.__builtin_isnan(x): both usefucomp st(0), since only a NaN is unordered with itself, and test C2.
What Zen 5 did
- A QNaN gave unordered and no IE, even with IE unmasked.
- An SNaN, or an unsupported encoding (an unnormal, a pseudo-infinity, a pseudo-NaN), raised IE and gave unordered.
- An empty register raised IE and SF, with C1 = 0, and gave unordered.
- A denormal raised DE and was compared: the smallest denormal came out greater than +0.
Intel’s manual says that an unmasked IE leaves the condition codes alone. With IE unmasked, Zen 5 still set them to unordered, for an SNaN and an empty register alike, and with DE unmasked to the compare’s result; #MF came at the next waiting instruction, and FUCOMP and FUCOMPP did not pop after an unmasked IE.
AMD’s Zen 5 guide lists FUCOM, FUCOMP and FUCOMPP as one macro-op each on pipe FP1, one per cycle.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
FUCOM st(i)
FUCOM_ST0_X87 | DD E0+i | FPU |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
if empty(st0) or empty(src):
underflow()
x = 3 # unordered
else:
x = ucomi(st0, src) # only an SNaN raises IE
c3 = x in (2, 3) # set with IE or DE unmasked too
c2 = x == 3
c0 = x in (1, 3)
c1 = 0Run on AMD Zen 5 (EPYC 9645): 38 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
FUCOM st(i) | ||
st(i) | explicit | read |
x87 status word | implicit | write |
Flags
| C0 | C1 | C2 | C3 |
|---|---|---|---|
| All forms | |||
| M | M | M | M |
Attributes
What else XED records about the forms. How to read.
- All forms
- may abort a TSX transaction
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
| ISA set | CPUID | Processors |
|---|---|---|
X87 | FPU | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
More x87 instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s
-marchfeature sets and AMD’s Processor Programming References, which the page of each processor cites. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2A, page 3-402 (FUCOM/
FUCOMP/ FUCOMPP) - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
- Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3 (325384-093, September 2026)
- AMD64 Architecture Programmer's Manual, Volume 5: 64-Bit Media and x87 Floating-Point Instructions (26569, rev. 3.16, November 2021), Wayback Machine copy of AMD's PDF
- Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The text is our own.