Instruction
VINSERTF128
Copies the first source to a YMM register and replaces the half an immediate selects with 128 bits from an XMM register or memory.
- Extensions
- Forms
- 2 (2 VEX)
- Data
- Intel XED v2026.08.23
VINSERTF128 copies a ymm source to the destination and replaces one 128-bit half of the copy with 16 bytes from an xmm register or memory: the low half when bit 0 of the immediate is 0, the high half when it is
- It does what VINSERTI128 does, and that page covers its uses (joining two halves, loading two rows, lane-wise code) and its EVEX successors. What sets it apart is that it needs only AVX, so it is the instruction that code for AVX alone has for building a ymm register out of xmm values.
Only bit 0 counts
The cases recorded on Zen 5 used immediates with other bits set:
vinsertf128 ymm4, ymm4, xmmword ptr [mem], 0x2Areplaced the low half with the 16 bytes from memory and kept ymm4’s high half;vinsertf128 ymm8, ymm15, xmm0, 0x45put xmm0 into the high half over a copy of ymm15’s low half.
Both cleared bits 256 to 511 of the destination’s zmm register, as a VEX instruction does.
In code for AVX
With -mavx, GCC 14 and Clang 23 at -O2 emit VINSERTF128 wherever
halves meet, for doubles and singles alike:
_mm256_set_m128d(hi, lo)and a shuffle that joins the low halves of two vectors arevinsertf128 ymm0, ymm0, xmm1, 1;_mm256_set1_pd(x)is VMOVDDUP and a VINSERTF128 of xmm0 into itself, since the register form of VBROADCASTSD needs AVX2;- setting element 0 of four doubles is, in GCC, VMOVSD into a copy of the low half and VINSERTF128 with an immediate of 0 to put it back; Clang uses VBLENDPS instead.
AMD’s Zen 5 guide lists the register and memory forms as one macro-op on the pipes FP1 and FP2 with a latency of 1 cycle, against 3 cycles for VPERM2F128, which can also join two halves.
In the optimization guide
What the optimization guide says about VINSERTF128, a line per claim. Each links to the claim in the guide, with its sources and where they differ.
Vectors
- Shuffles and lane crossing: Most 256-bit AVX instructions stay within 128-bit lanes, and loading each lane with VINSERTF128 avoids shuffles across them.
Crestmont and Gracemont
- Vectors and AVX2: The 256-bit forms that widen or insert data loaded from memory take two dependent micro-ops.
Sandy Bridge and Ivy Bridge
- AVX, SSE and denormals: Moving data between a YMM register’s two 128-bit halves always costs one extra cycle: VINSERTF128, which does this, has a latency of 2 cycles against the 1 cycle of a shuffle or blend that stays within one half.
Zen and Zen+
- Vectors and floating point: VPERM2F128 is microcoded, three cycles in AMD’s spreadsheet and eight macro-ops in LLVM’s model, while VINSERTF128 and VEXTRACTF128, which move one 128-bit half, take a cycle; moving halves with them beats a full permute. sources differ
Forms
Data flow
Where the elements of the sources go, element 0 on the right; results that depend on a control value are drawn for an example. How to read.
Example: imm8 = 0x02.
With imm8 = 0x02, result quadwords 3 to 0: a3, a2, b1, b0.
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
ymm1.write(ymm2.read())
ymm1.dq[imm8 & 1] = src3.dq[0]
# ymm1 is zeroed from bit 256 upRun on AMD Zen 5 (EPYC 9645): 2 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
VINSERTF128 ymm, ymm, xmm/m128, imm8 | ||
ymm | explicit | write |
ymm | explicit | read |
xmm/m128 | explicit | read |
imm8 | explicit | read |
Flags
None: XED records no flag that the forms test or change.
Exceptions
The exception class is XED's name for the set of exception conditions that a form follows. How to read.
- All forms
avx-type-6
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to VINSERTF128, each with the form it compiles to and the Clang options it needs. The forms come from compiling every intrinsic and decoding the result with Intel XED; all intrinsics A–Z explains the method.
| Intrinsic | Compiles to |
|---|---|
_mm256_broadcast_f32x4
__m256 _mm256_broadcast_f32x4(__m128 __A) |
|
_mm256_broadcast_f64x2
__m256d _mm256_broadcast_f64x2(__m128d __A) |
|
_mm256_insertf128_pd
__m256d _mm256_insertf128_pd(__m256d V1, __m128d V2, const int M) |
|
_mm256_insertf128_ps
__m256 _mm256_insertf128_ps(__m256 V1, __m128 V2, const int M) |
|
_mm256_insertf128_si256
__m256i _mm256_insertf128_si256(__m256i V1, __m128i V2, const int M) |
|
_mm256_insertf32x4
__m256 _mm256_insertf32x4(__m256 A, __m128 B, const int imm) |
|
_mm256_insertf64x2
__m256d _mm256_insertf64x2(__m256d A, __m128d B, const int imm) |
|
_mm256_set_m128
__m256 _mm256_set_m128(__m128 __hi, __m128 __lo) |
|
_mm256_set_m128d
__m256d _mm256_set_m128d(__m128d __hi, __m128d __lo) |
|
_mm256_set_m128i
__m256i _mm256_set_m128i(__m128i __hi, __m128i __lo) |
|
_mm256_setr_m128
__m256 _mm256_setr_m128(__m128 __lo, __m128 __hi) |
|
_mm256_setr_m128d
__m256d _mm256_setr_m128d(__m128d __lo, __m128d __hi) |
|
_mm256_setr_m128i
__m256i _mm256_setr_m128i(__m128i __lo, __m128i __hi) |
|
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 |
|---|---|---|
AVX | AVX | Sandy Bridge, Ivy Bridge, Haswell, Broadwell, Skylake, Comet Lake, Cannon Lake, Ice Lake (client), Tiger Lake, Alder Lake, Arrow Lake, Panther Lake, Nova Lake, Skylake-SP, Cascade Lake, Cooper Lake, Ice Lake (server), Sapphire Rapids, Emerald Rapids, Granite Rapids, Diamond Rapids, Sierra Forest, Clearwater Forest, Knights Landing, Knights Mill, Bulldozer, Piledriver, Zen, Zen+, Zen 2, Zen 3, Zen 4, Zen 5, Zen 6 |
More AVX instructions
- VCVTSI2SD
- VCVTSI2SS
- VCVTSS2SD
- VCVTSS2SI
- VCVTTPD2DQ
- VCVTTPS2DQ
- VCVTTSD2SI
- VCVTTSS2SI
- VDIVPD
- VDIVPS
- VDIVSD
- VDIVSS
- VDPPD
- VDPPS
- VEXTRACTF128
- VEXTRACTPS
- VHADDPD
- VHADDPS
- VHSUBPD
- VHSUBPS
- VINSERTPS
- VLDDQU
- VLDMXCSR
- VMASKMOVDQU
- VMASKMOVPD
- VMASKMOVPS
- VMAXPD
- VMAXPS
- VMAXSD
- VMAXSS
- VMINPD
- VMINPS
- VMINSD
- VMINSS
- VMOVAPD
- VMOVAPS
- VMOVD
- VMOVDDUP
- VMOVDQA
- VMOVDQU
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. - Clang's x86 intrinsic headers, LLVM 23.1.2 (commit
85ac56026243): the intrinsics, their signatures and doc comments, and the Clang of that release, which compiled each of them. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2C, page 5-406 (VINSERTF128/
VINSERTF32x4/ VINSERTF64x2/ VINSERTF32x8/ VINSERTF64x4) - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 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 intrinsics and their signatures come from Clang, part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.