FMA instruction set


The FMA instruction set is an extension to the 128 and 256-bit Streaming SIMD Extensions instructions in the x86 microprocessor instruction set to perform fused multiply–add operations. There are two variants:
FMA3 and FMA4 instructions have almost identical functionality, but are not compatible. Both contain fused multiply–add instructions for floating-point scalar and SIMD operations, but FMA3 instructions have three operands, while FMA4 ones have four. The FMA operation has the form d = round, where the round function performs a rounding to allow the result to fit within the destination register if there are too many significant bits to fit within the destination.
The four-operand form allows a, b, c and d to be four different registers, while the three-operand form requires that d be the same register as a, b or c. The three-operand form makes the code shorter and the hardware implementation slightly simpler, while the four-operand form provides more programming flexibility.
See XOP instruction set for more discussion of compatibility issues between Intel and AMD.

FMA3 instruction set

CPUs with FMA3

Supported commands include VFMADD, VFMADDSUB, VFMSUBADD, VFMSUB, VFNMADD, VFNMSUB. Explicit order of operands is included in the mnemomic using numbers "132", "213", and "231", as well as operand format and size.
Mnemonic OperandsOperation
VFMADD132PDyymm, ymm, ymm/m256a = a·c + b
VFMADD132PSyymm, ymm, ymm/m256a = a·c + b
VFMADD132PDxxmm, xmm, xmm/m128a = a·c + b
VFMADD132PSxxmm, xmm, xmm/m128a = a·c + b
VFMADD132SDxmm, xmm, xmm/m64a = a·c + b
VFMADD132SSxmm, xmm, xmm/m32a = a·c + b
VFMADD213PDyymm, ymm, ymm/m256a = b·a + c
VFMADD213PSyymm, ymm, ymm/m256a = b·a + c
VFMADD213PDxxmm, xmm, xmm/m128a = b·a + c
VFMADD213PSxxmm, xmm, xmm/m128a = b·a + c
VFMADD213SDxmm, xmm, xmm/m64a = b·a + c
VFMADD213SSxmm, xmm, xmm/m32a = b·a + c
VFMADD231PDyymm, ymm, ymm/m256a = b·c + a
VFMADD231PSyymm, ymm, ymm/m256a = b·c + a
VFMADD231PDxxmm, xmm, xmm/m128a = b·c + a
VFMADD231PSxxmm, xmm, xmm/m128a = b·c + a
VFMADD231SDxmm, xmm, xmm/m64a = b·c + a
VFMADD231SSxmm, xmm, xmm/m32a = b·c + a

FMA4 instruction set

CPUs with FMA4

History

The incompatibility between Intel's FMA3 and AMD's FMA4 is due to both companies changing plans without coordinating coding details with each other. AMD changed their plans from FMA3 to FMA4 while Intel changed their plans from FMA4 to FMA3 almost at the same time. The history can be summarized as follows:
Different compilers provide different levels of support for FMA: