Instruction
VALIGND
Concatenates two vectors and extracts one vector's worth of doublewords starting at an element offset given by an immediate.
- Extensions
- Forms
- 6 (6 EVEX)
- Data
- Intel XED v2026.08.23
VALIGND joins its first source above its second and extracts one register’s worth of doublewords starting at the element the immediate names. With an offset of 3 on ZMM registers, the result is elements 3 to 15 of the second source followed by elements 0 to 2 of the first. The operand order is that of PALIGNR, but the shift counts doublewords instead of bytes and runs across the whole register, not within each 128-bit lane as VPALIGNR does. VALIGNQ counts quadwords.
The offset wraps
Only as many low bits of the immediate count as the element count needs:
two for XMM, three for YMM, four for ZMM. Larger values wrap instead of
shifting in zeros as PALIGNR does, so VALIGND never brings in zeros by
itself. In the cases recorded on Zen 5, immediate 5 on XMM registers
acted as 1, and FFh on YMM registers as 7. A shift that should bring in
zeros takes a zeroed register as the second source. At -O2 with
-march=x86-64-v4, GCC 14 passes _mm512_alignr_epi32(a, b, 17) to the
assembler as 17, while Clang 23 reduces it to 1, the same instruction in
effect.
Rotating and shifting by elements
With the same register in both sources, VALIGND rotates it by whole
elements across lanes. For a rotation of sixteen int by one written
with __builtin_shufflevector, Clang 23 emits
valignd zmm0, zmm0, zmm0, 1, and for a shift by one element that
brings in a zero, VALIGND with a zeroed register and offset 15. GCC 14
uses VPERMD for the rotation and
VPERMI2D for the shift, each with an index vector
loaded from memory. The VPALIGNR page shows VALIGND in Clang’s sliding
windows, and the VPSHLDD page how it helps shift a
whole register by bits.
Masks and broadcast
The write mask applies per doubleword of the result. A broadcast operand makes the second source one value repeated, and VALIGND then shifts copies of it in: in a recorded case with offset 3, the broadcast doubleword went to every selected element from 0 to 12, and the first three elements of the other source landed in 13 to 15.
AMD’s Zen 5 guide lists VALIGND as one macro-op with a latency of 2, 4 and 5 cycles for XMM, YMM and ZMM.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
VALIGND zmm {k}{z}, zmm, zmm, imm8
VALIGND_ZMMu32_MASKmskw_ZMMu32_ZMMu32_IMM8_AVX512 | EVEX.512.66.0F3A.W0 03 /r ib | AVX10.1 or AVX512F |
VALIGND zmm {k}{z}, zmm, m512/m32bcst, imm8
VALIGND_ZMMu32_MASKmskw_ZMMu32_MEMu32_IMM8_AVX512 | EVEX.512.66.0F3A.W0 03 /r ib | AVX10.1 or AVX512F |
VALIGND xmm {k}{z}, xmm, xmm, imm8
VALIGND_XMMu32_MASKmskw_XMMu32_XMMu32_IMM8_AVX512 | EVEX.128.66.0F3A.W0 03 /r ib | AVX10.1 or AVX512F + AVX512VL |
VALIGND xmm {k}{z}, xmm, m128/m32bcst, imm8
VALIGND_XMMu32_MASKmskw_XMMu32_MEMu32_IMM8_AVX512 | EVEX.128.66.0F3A.W0 03 /r ib | AVX10.1 or AVX512F + AVX512VL |
VALIGND ymm {k}{z}, ymm, ymm, imm8
VALIGND_YMMu32_MASKmskw_YMMu32_YMMu32_IMM8_AVX512 | EVEX.256.66.0F3A.W0 03 /r ib | AVX10.1 or AVX512F + AVX512VL |
VALIGND ymm {k}{z}, ymm, m256/m32bcst, imm8
VALIGND_YMMu32_MASKmskw_YMMu32_MEMu32_IMM8_AVX512 | EVEX.256.66.0F3A.W0 03 /r ib | AVX10.1 or AVX512F + AVX512VL |
Latency and throughput
| Model | zmm {k}{z}, zmm, zmm, imm8no mask | zmm {k}{z}, zmm, zmm, imm8with a mask, zeroing | zmm {k}{z}, zmm, m512/m32bcst, imm8 | xmm {k}{z}, xmm, xmm, imm8no mask | xmm {k}{z}, xmm, xmm, imm8with a mask, zeroing | xmm {k}{z}, xmm, m128/m32bcst, imm8 | ymm {k}{z}, ymm, ymm, imm8no mask | ymm {k}{z}, ymm, ymm, imm8with a mask, zeroing | ymm {k}{z}, ymm, m256/m32bcst, imm8 |
|---|---|---|---|---|---|---|---|---|---|
| Skylake-SP, Ice Lake | 3 / 1p5 | 3 / 1p5 | 10 / 1p5 | 3 / 1p5 | 3 / 1p5 | 9 / 1p5 | 3 / 1p5 | 3 / 1p5 | 10 / 1p5 |
| Sapphire Rapids | 3 / 1p5 | 3 / 1p5 | 11 / 1p5 | 1 / 1p5 | 1 / 1p5 | 8 / 1p5 | 3 / 1p5 | 3 / 1p5 | 11 / 1p5 |
| Zen 4 | 2 / 0.51FP1 FP2 | 1 / 11FP1 FP2 | 8 / 1FP1 FP2 | 3 / 0.52FP1 FP2 | 1 / 0.52FP1 FP2 | 8 / 0.5FP1 FP2 | 4 / 13FP1 FP2 | 1 / 0.54FP1 FP2 | 8 / 0.5FP1 FP2 |
- Zen 4 model: AMD's spreadsheets give latency 5 for Zen 4 and Zen 5 (AMD 57647, row 861; AMD 58455, row 378).
- Zen 4 model: AMD's spreadsheets give latency 2 for Zen 4 and Zen 5 (AMD 57647, row 859; AMD 58455, row 376).
- Zen 4 model: AMD's spreadsheets give reciprocal throughput 0.5 for Zen 4 and Zen 5 (AMD 57647, row 860; AMD 58455, row 377).
- Zen 4 model: AMD's spreadsheets give latency 4 for Zen 4 and Zen 5 (AMD 57647, row 860; AMD 58455, row 377).
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 = 5. Shown for the zmm form; the xmm and ymm forms work the same on 4 and 8 doublewords. The forms write under a mask: where its bit is 0, the element keeps its old value, or zeroes it with {z}. With m32bcst, one doubleword from memory stands for every element of zmm3.
With imm8 = 5, result doublewords 15 to 0: a4, unchanged (bit 14 of k1 is 0), a2, a1, a0, b15, b14, b13, b12, b11, b10, b9, b8, b7, b6, b5.
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
n = VL // 32 # 4 in xmm, 8 in ymm, 16 in zmm
for i in range(n):
j = i + (imm8 & n - 1) # element j of zmm2:src3
if k1[i]:
if j < n:
zmm1.d[i] = src3.d[j]
else:
zmm1.d[i] = zmm2.d[j - n]
elif zeroing:
zmm1.d[i] = 0
# else: zmm1.d[i] keeps its value
# m32bcst: src3.d[i] is the m32 for every i
# zmm1 is zeroed from bit VL upRun on AMD Zen 5 (EPYC 9645): 6 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
VALIGND xmm {k}{z}, xmm, xmm/m128/m32bcst, imm8 VALIGND ymm {k}{z}, ymm, ymm/m256/m32bcst, imm8 VALIGND zmm {k}{z}, zmm, zmm/m512/m32bcst, imm8 | ||
xmm, ymm, zmm | explicit | write (masked) |
{k} | explicit | read (write mask) |
xmm, ymm, zmm | explicit | read |
xmm/m128/m32bcst, ymm/m256/m32bcst, zmm/m512/m32bcst | 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
AVX512-E4NF
Attributes
What else XED records about the forms. How to read.
- All forms
- write masking
- Memory forms
- embedded broadcast (tuple Full)
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to VALIGND, 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 |
|---|---|
_mm_mask_alignr_epi32
__m128i _mm_mask_alignr_epi32(__m128i W, __mmask8 U, __m128i A, __m128i B, const int imm) |
|
_mm_maskz_alignr_epi32
__m128i _mm_maskz_alignr_epi32(__mmask8 U, __m128i A, __m128i B, const int imm) |
|
_mm256_alignr_epi32
__m256i _mm256_alignr_epi32(__m256i A, __m256i B, const int imm) |
|
_mm256_mask_alignr_epi32
__m256i _mm256_mask_alignr_epi32(__m256i W, __mmask8 U, __m256i A, __m256i B, const int imm) |
|
_mm256_maskz_alignr_epi32
__m256i _mm256_maskz_alignr_epi32(__mmask8 U, __m256i A, __m256i B, const int imm) |
|
_mm512_alignr_epi32
__m512i _mm512_alignr_epi32(__m512i A, __m512i B, const int I) |
|
_mm512_mask_alignr_epi32
__m512i _mm512_mask_alignr_epi32(__m512i W, __mmask16 U, __m512i A, __m512i B, const int imm) |
|
_mm512_maskz_alignr_epi32
__m512i _mm512_maskz_alignr_epi32(__mmask16 U, __m512i A, __m512i B, const int imm) |
|
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 |
|---|---|---|
AVX512F_512 | AVX10.1 or AVX512F | Cannon Lake, Ice Lake (client), Tiger Lake, Nova Lake, Skylake-SP, Cascade Lake, Cooper Lake, Ice Lake (server), Sapphire Rapids, Emerald Rapids, Granite Rapids, Diamond Rapids, Knights Landing, Knights Mill, Zen 4, Zen 5, Zen 6 |
AVX512F_128 | AVX10.1 or AVX512F + AVX512VL | Cannon Lake, Ice Lake (client), Tiger Lake, Nova Lake, Skylake-SP, Cascade Lake, Cooper Lake, Ice Lake (server), Sapphire Rapids, Emerald Rapids, Granite Rapids, Diamond Rapids, Zen 4, Zen 5, Zen 6 |
AVX512F_256 | Same as AVX512F_128 | Same as AVX512F_128 |
More AVX10.1 instructions
- KUNPCKDQ
- KUNPCKWD
- KXNORB
- KXNORD
- KXNORQ
- KXNORW
- KXORB
- KXORD
- KXORQ
- KXORW
- VADDPD
- VADDPH
- VADDPS
- VADDSD
- VADDSH
- VADDSS
- VAESDEC
- VAESDECLAST
- VAESENC
- VAESENCLAST
- VALIGNQ
- VANDNPD
- VANDNPS
- VANDPD
- VANDPS
- VBLENDMPD
- VBLENDMPS
- VBROADCASTF32X2
- VBROADCASTF32X4
- VBROADCASTF32X8
- VBROADCASTF64X2
- VBROADCASTF64X4
- VBROADCASTI32X2
- VBROADCASTI32X4
- VBROADCASTI32X8
- VBROADCASTI64X2
- VBROADCASTI64X4
- VBROADCASTSD
- VBROADCASTSS
- VCMPPD
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. - LLVM 23.1.2's x86 scheduling models (commit
85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them. - Intel Advanced Vector Extensions 10.2 Architecture Specification, revision 7.0 (361050-007, April 2026)
- Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2C, page 5-4 (VALIGND/
VALIGNQ) - 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 and the timings from LLVM's scheduling models, both part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.