Instruction
VALIGNQ
Concatenates two vectors and extracts one vector's worth of quadwords starting at an element offset given by an immediate.
- Extensions
- Forms
- 6 (6 EVEX)
- Data
- Intel XED v2026.08.23
VALIGNQ is VALIGND counting quadwords: it joins its first source above its second and extracts one register’s worth of quadwords from the element the immediate names. That page compares it with PALIGNR and VPALIGNR and shows how a zeroed register makes a shift. Since a ZMM register holds 8 quadwords, only three bits of the immediate count at 512 bits, two at 256 and one at 128, and larger values wrap.
Recorded on Zen 5
- The wrap. With FFh,
valignq xmm17, xmm30, xmm2, 0xffacted as offset 1, giving the high quadword of XMM2 below the low one of XMM30, andvalignq ymm0{k2}, ymm31, ymmword ptr [mem], 0xffas offset 3. - Offset 5 at 512 bits.
valignq zmm17{k7}, zmm30, zmm2, 0x5computed quadwords 5 to 7 of ZMM2 followed by 0 to 4 of ZMM30 and wrote the five that E3h selects, 0, 1 and 5 to 7. - Offset 0 returns the second source unchanged: with a
qword bcstoperand, the same mask wrote the one quadword to those five elements.
In compiled code
Clang 23 at -O2 with -march=x86-64-v4 uses VALIGNQ for what
__builtin_shufflevector writes as a window of two vectors of eight
long long or double, as a rotation by one element and as a shift
that brings in a zero from a zeroed register. GCC 14 loads an index
vector for each instead and uses VPERMQ for the
rotation and VPERMI2Q or VPERMI2PD for the others.
In a loop over long long arrays, h[i] = g[i] + g[i+1], Clang loads
each vector once and builds the shifted one with VALIGNQ on ymm
registers, carrying the previous vector over; GCC loads the array a
second time, eight bytes further on. As with VALIGND, GCC passes
_mm512_alignr_epi64(a, b, 9) on as 9 and Clang reduces it to 1.
AMD’s Zen 5 latency spreadsheet gives VALIGNQ 2, 3 and 5 cycles for XMM, YMM and ZMM registers, where VALIGND takes 4 at YMM, and two per cycle on pipes FP1 and FP2. Zen 5’s 6 recorded cases cover the register, memory and broadcast forms at all three widths.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
VALIGNQ zmm {k}{z}, zmm, zmm, imm8
VALIGNQ_ZMMu64_MASKmskw_ZMMu64_ZMMu64_IMM8_AVX512 | EVEX.512.66.0F3A.W1 03 /r ib | AVX10.1 or AVX512F |
VALIGNQ zmm {k}{z}, zmm, m512/m64bcst, imm8
VALIGNQ_ZMMu64_MASKmskw_ZMMu64_MEMu64_IMM8_AVX512 | EVEX.512.66.0F3A.W1 03 /r ib | AVX10.1 or AVX512F |
VALIGNQ xmm {k}{z}, xmm, xmm, imm8
VALIGNQ_XMMu64_MASKmskw_XMMu64_XMMu64_IMM8_AVX512 | EVEX.128.66.0F3A.W1 03 /r ib | AVX10.1 or AVX512F + AVX512VL |
VALIGNQ xmm {k}{z}, xmm, m128/m64bcst, imm8
VALIGNQ_XMMu64_MASKmskw_XMMu64_MEMu64_IMM8_AVX512 | EVEX.128.66.0F3A.W1 03 /r ib | AVX10.1 or AVX512F + AVX512VL |
VALIGNQ ymm {k}{z}, ymm, ymm, imm8
VALIGNQ_YMMu64_MASKmskw_YMMu64_YMMu64_IMM8_AVX512 | EVEX.256.66.0F3A.W1 03 /r ib | AVX10.1 or AVX512F + AVX512VL |
VALIGNQ ymm {k}{z}, ymm, m256/m64bcst, imm8
VALIGNQ_YMMu64_MASKmskw_YMMu64_MEMu64_IMM8_AVX512 | EVEX.256.66.0F3A.W1 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/m64bcst, imm8 | xmm {k}{z}, xmm, xmm, imm8no mask | xmm {k}{z}, xmm, xmm, imm8with a mask, zeroing | xmm {k}{z}, xmm, m128/m64bcst, imm8 | ymm {k}{z}, ymm, ymm, imm8no mask | ymm {k}{z}, ymm, ymm, imm8with a mask, zeroing | ymm {k}{z}, ymm, m256/m64bcst, 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.5FP1 FP2 | 1 / 1FP1 FP2 | 8 / 1FP1 FP2 | 3 / 0.51FP1 FP2 | 1 / 0.51FP1 FP2 | 8 / 0.5FP1 FP2 | 4 / 12FP1 FP2 | 1 / 0.52FP1 FP2 | 8 / 0.5FP1 FP2 |
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 = 3. Shown for the zmm form; the xmm and ymm forms work the same on 2 and 4 quadwords. The forms write under a mask: where its bit is 0, the element keeps its old value, or zeroes it with {z}. With m64bcst, one quadword from memory stands for every element of zmm3.
With imm8 = 3, result quadwords 7 to 0: a2, unchanged (bit 6 of k1 is 0), a0, b7, b6, b5, b4, b3.
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
n = VL // 64 # 2 in xmm, 4 in ymm, 8 in zmm
for i in range(n):
j = i + (imm8 & n - 1) # element j of zmm2:src3
if k1[i]:
if j < n:
zmm1.q[i] = src3.q[j]
else:
zmm1.q[i] = zmm2.q[j - n]
elif zeroing:
zmm1.q[i] = 0
# else: zmm1.q[i] keeps its value
# m64bcst: src3.q[i] is the m64 for every i
# zmm1 is zeroed from bit VL upRun on AMD Zen 5 (EPYC 9645): 6 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
VALIGNQ xmm {k}{z}, xmm, xmm/m128/m64bcst, imm8 VALIGNQ ymm {k}{z}, ymm, ymm/m256/m64bcst, imm8 VALIGNQ zmm {k}{z}, zmm, zmm/m512/m64bcst, imm8 | ||
xmm, ymm, zmm | explicit | write (masked) |
{k} | explicit | read (write mask) |
xmm, ymm, zmm | explicit | read |
xmm/m128/m64bcst, ymm/m256/m64bcst, zmm/m512/m64bcst | 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 VALIGNQ, 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 |
|---|---|
_mm512_alignr_epi64
__m512i _mm512_alignr_epi64(__m512i A, __m512i B, const int I) |
|
_mm512_mask_alignr_epi64
__m512i _mm512_mask_alignr_epi64(__m512i W, __mmask8 U, __m512i A, __m512i B, const int imm) |
|
_mm512_maskz_alignr_epi64
__m512i _mm512_maskz_alignr_epi64(__mmask8 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
- KUNPCKWD
- KXNORB
- KXNORD
- KXNORQ
- KXNORW
- KXORB
- KXORD
- KXORQ
- KXORW
- VADDPD
- VADDPH
- VADDPS
- VADDSD
- VADDSH
- VADDSS
- VAESDEC
- VAESDECLAST
- VAESENC
- VAESENCLAST
- VALIGND
- VANDNPD
- VANDNPS
- VANDPD
- VANDPS
- VBLENDMPD
- VBLENDMPS
- VBROADCASTF32X2
- VBROADCASTF32X4
- VBROADCASTF32X8
- VBROADCASTF64X2
- VBROADCASTF64X4
- VBROADCASTI32X2
- VBROADCASTI32X4
- VBROADCASTI32X8
- VBROADCASTI64X2
- VBROADCASTI64X4
- VBROADCASTSD
- VBROADCASTSS
- VCMPPD
- VCMPPH
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.