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

  1. 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], 0x2A replaced the low half with the 16 bytes from memory and kept ymm4’s high half;
  • vinsertf128 ymm8, ymm15, xmm0, 0x45 put 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 are vinsertf128 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

Every encoding of VINSERTF128 that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
VINSERTF128 ymm, ymm, m128, imm8 VINSERTF128_YMMqq_YMMqq_MEMdq_IMMbVEX.256.66.0F3A.W0 18 /r ibAVX
VINSERTF128 ymm, ymm, xmm, imm8 VINSERTF128_YMMqq_YMMqq_XMMdq_IMMbVEX.256.66.0F3A.W0 18 /r ibAVX

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.

Insert: xmm3 replaces the 128-bit block of ymm2 that imm8 numbers; the rest of the result comes from ymm2.
VINSERTF128 with imm8 = 0x02With imm8 = 0x02, result quadwords 3 to 0: a3, a2, b1, b0.0123ymm2ab0b1a2a3ymm101xmm3or m128b

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 up

Run on AMD Zen 5 (EPYC 9645): 2 cases.

Operands

What each form reads and writes, as Intel XED records it: the operands of its syntax, in order, and the implicit ones that the syntax does not name. How to read.
OperandKindAction
VINSERTF128 ymm, ymm, xmm/m128, imm8
ymmexplicitwrite
ymmexplicitread
xmm/m128explicitread
imm8explicitread

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.

IntrinsicCompiles to
_mm256_broadcast_f32x4 __m256 _mm256_broadcast_f32x4(__m128 __A)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx512vl

_mm256_broadcast_f64x2 __m256d _mm256_broadcast_f64x2(__m128d __A)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx512vl -mavx512dq

_mm256_insertf128_pd __m256d _mm256_insertf128_pd(__m256d V1, __m128d V2, const int M)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx

_mm256_insertf128_ps __m256 _mm256_insertf128_ps(__m256 V1, __m128 V2, const int M)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx

_mm256_insertf128_si256 __m256i _mm256_insertf128_si256(__m256i V1, __m128i V2, const int M)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx

_mm256_insertf32x4 __m256 _mm256_insertf32x4(__m256 A, __m128 B, const int imm)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx512vl

_mm256_insertf64x2 __m256d _mm256_insertf64x2(__m256d A, __m128d B, const int imm)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx512vl -mavx512dq

_mm256_set_m128 __m256 _mm256_set_m128(__m128 __hi, __m128 __lo)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx

_mm256_set_m128d __m256d _mm256_set_m128d(__m128d __hi, __m128d __lo)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx

_mm256_set_m128i __m256i _mm256_set_m128i(__m128i __hi, __m128i __lo)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx

_mm256_setr_m128 __m256 _mm256_setr_m128(__m128 __lo, __m128 __hi)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx

_mm256_setr_m128d __m256d _mm256_setr_m128d(__m128d __lo, __m128d __hi)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx

_mm256_setr_m128i __m256i _mm256_setr_m128i(__m128i __lo, __m128i __hi)

VINSERTF128 ymm, ymm, xmm, imm8 VEX.256 -mavx

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.

CPUID requirements and processors of the XED ISA sets above. Alternatives are separated by “or”; processors follow XED’s chip model, whose AMD processors end with Zen 2, and the CPU data of this site for Zen 3 to Zen 6.

More AVX instructions

All 253 AVX instructions

Sources

  1. Intel XED v2026.08.23 (commit 0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model.
  2. The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s -march feature sets and AMD’s Processor Programming References, which the page of each processor cites.
  3. 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.
  4. 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)
  5. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
  6. 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.