Instruction
FISTP
Converts ST(0) to a 16-, 32- or 64-bit signed integer as the rounding control says, stores it and pops the register stack.
- Extensions
- Forms
- 3 (3 Legacy)
- Data
- Intel XED v2026.08.23
FISTP converts ST(0) to a signed 16-, 32- or 64-bit integer, stores it and pops. The conversion rounds as RC says, which is to nearest even unless code changes it, so 2.5 becomes 2 and -1.5 becomes -2. FIST stores without popping and has no 64-bit form; only FISTP writes a 64-bit integer.
Casts and the control word
C’s casts truncate, so compilers change RC around the store. GCC 14 and
Clang 23 at -O2 compile (long)x on a long double to
fnstcwof the control word to the stack, and a copy withor ah, 12(Clang:or eax, 3072), which sets RC to toward zero,- FLDCW of the copy,
fistp QWORD PTR, and FLDCW of the saved word to restore it.
Intel’s optimization manual counts these changes of the control word as
the cost of x87 conversions (Section 3.9.3.1). With -msse3, both
compilers emit FISTTP instead, which truncates whatever
RC says and needs no FLDCW. lrintl(x), which rounds by the current
mode, becomes a bare fistp once -fno-math-errno lets them inline it.
In 32-bit code, (long long)d uses this sequence even when the
arithmetic uses SSE2, which has no 64-bit integer conversion there.
Out of range
A NaN, an infinity, or a value whose rounded integer does not fit gives the integer indefinite, the most negative integer of the size (8000H, 80000000H or 8000000000000000H), with IE set: Zen 5 stored 8000H for 32768.0 into 16 bits. With IE unmasked, nothing is stored and nothing popped. So a 16-bit FISTP is no unsigned-short conversion: values from 32768 up do not fit.
For (unsigned long)x both compilers compare x with 2^63, subtract 2^63
from larger values before the FISTP and flip bit 63 of the result
afterwards.
AMD’s Zen 5 guide lists FISTP to memory, like FISTTP, as two macro-ops.
Forms
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
if empty(st0):
underflow()
v = INDEFINITE
else:
v = st0
r = cvt_int(v, dest.bits) # rounded by RC; a NaN, an
# infinity or a number out of
# range gives the integer
# indefinite, with IE
dest.write(r)
pop()
c0 = c2 = c3 = UNDEFINEDRun on AMD Zen 5 (EPYC 9645): 45 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
FISTP m16int FISTP m32int FISTP m64int | ||
m16/32/64int | explicit | write |
x87 register stack | implicit | pop |
x87 status word | implicit | write |
Flags
| C0 | C1 | C2 | C3 |
|---|---|---|---|
| All forms | |||
| U | M | U | U |
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-347 (FIST/
FISTP) - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-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
- Intel 64 and IA-32 Architectures Optimization Reference Manual, Volume 1 (248966-051, October 2026)
- 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.