Instruction
VAESENCLAST
Performs the last round of AES encryption on each 128-bit lane with the round key of the matching lane.
VAESENCLAST runs the last round of AES encryption, SubBytes, ShiftRows and the XOR with a round key, on every 128-bit lane of its second operand, with the key from the same lane of the third. AESENCLAST’s page covers the round and its uses as a 16-byte S-box and for folding the plaintext into the last key; the forms are those of VAESENC: VEX.128 for AES and AVX, VEX.256 for VAES, and EVEX for VAES with AVX512F (AVX512VL below 512 bits) or AVX10.1, without masking or broadcast. Each form writes a separate destination, cleared above the vector length, and takes memory at any alignment.
Both uses widen with the lanes. With a zero key, a ZMM VAESENCLAST looks up 64 bytes in the S-box, in ShiftRows order within each lane, which VPSHUFB, also confined to lanes, can undo. In CTR mode each lane holds its own counter and plaintext block, so the last key XORed with four plaintext blocks gives four different keys, which VAESENCLAST takes as they are.
Recorded on Zen 5
The 22 recorded cases cover every form. In {evex} vaesenclast zmm1, zmm2, zmm3, lane 0, zero state and key, gave 63h in every byte; lane 1
finished the AES-128 example of FIPS-197, turning
BD6E7C3DF2B5779E0B61216E8B10B689 with the last round key
13111D7FE3944A17F307A78B4D2B30C5 into the example’s ciphertext,
69C4E0D86A7B0430D8CDB78070B4C55A; lane 2, all ones, gave E9h.
In compiled code
In our builds at -O2 with -march=znver5, a CTR step on four counters
in a ZMM register, _mm512_aesenclast_epi128 after nine
_mm512_aesenc_epi128, ends with VAESENCLAST and a VPXORD (GCC 14) or
VPXORQ (Clang 23) of the plaintext from memory: neither compiler folds
the plaintext into the key. Each round key is loaded with
VBROADCASTI32X4.
AMD’s latency spreadsheet for Zen 5 gives the VEX and the EVEX rows alike a latency of 4 cycles, two per cycle on pipes FP0 and FP1, as for AESENCLAST.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
VAESENCLAST xmm, xmm, xmm
VAESENCLAST_XMMdq_XMMdq_XMMdq | VEX.128.66.0F38.WIG DD /r | AES + AVX |
VAESENCLAST xmm, xmm, m128
VAESENCLAST_XMMdq_XMMdq_MEMdq | VEX.128.66.0F38.WIG DD /r | AES + AVX |
VAESENCLAST ymm, ymm, ymm
VAESENCLAST_YMMu128_YMMu128_YMMu128 | VEX.256.66.0F38.WIG DD /r | VAES |
VAESENCLAST ymm, ymm, m256
VAESENCLAST_YMMu128_YMMu128_MEMu128 | VEX.256.66.0F38.WIG DD /r | VAES |
VAESENCLAST xmm, xmm, xmm
VAESENCLAST_XMMu128_XMMu128_XMMu128_AVX512 | EVEX.128.66.0F38.WIG DD /r | AVX10.1 + VAES or VAES + AES + AVX512F + AVX512VL |
VAESENCLAST xmm, xmm, m128
VAESENCLAST_XMMu128_XMMu128_MEMu128_AVX512 | EVEX.128.66.0F38.WIG DD /r | AVX10.1 + VAES or VAES + AES + AVX512F + AVX512VL |
VAESENCLAST ymm, ymm, ymm
VAESENCLAST_YMMu128_YMMu128_YMMu128_AVX512 | EVEX.256.66.0F38.WIG DD /r | AVX10.1 + VAES or VAES + AES + AVX512F + AVX512VL |
VAESENCLAST ymm, ymm, m256
VAESENCLAST_YMMu128_YMMu128_MEMu128_AVX512 | EVEX.256.66.0F38.WIG DD /r | AVX10.1 + VAES or VAES + AES + AVX512F + AVX512VL |
VAESENCLAST zmm, zmm, zmm
VAESENCLAST_ZMMu128_ZMMu128_ZMMu128_AVX512 | EVEX.512.66.0F38.WIG DD /r | AVX10.1 + VAES or VAES + AES + AVX512F |
VAESENCLAST zmm, zmm, m512
VAESENCLAST_ZMMu128_ZMMu128_MEMu128_AVX512 | EVEX.512.66.0F38.WIG DD /r | AVX10.1 + VAES or VAES + AES + AVX512F |
Latency and throughput
| Model | xmm, xmm, xmmymm, ymm, ymm | xmm, xmm, m128ymm, ymm, m256 | zmm, zmm, zmm | zmm, zmm, m512 |
|---|---|---|---|---|
| Sandy Bridge | 7 / 1p015 | 13 / 1p015 | ||
| Haswell | 7 / 1p5 | 13 / 1p5 | ||
| Broadwell | 7 / 1p5 | 12 / 1p5 | ||
| Skylake, Skylake-SP | 4 / 1p0 | 10 / 1p0 | ||
| Ice Lake | 4 / 1p0 | 10 / 1p0 | 4 / 1p0 | 10 / 1p0 |
| Alder Lake | 5 / 0.5p01 | 12 / 0.5p01 | ||
| Sapphire Rapids | 5 / 0.5p01 | 12 / 0.5p01 | 5 / 1p0 | 12 / 1p0 |
| Lunar Lake | 3 / 2V0 V1 | 11 / 2.33V0 V1 | ||
| Piledriver | 9 / 1FPMMA FPU0 | 14 / 1.5FPMMA FPU0 | ||
| Zen, Zen 2 | 4 / 0.5FPU0 FPU1 | 11 / 0.5FPU0 FPU1 | ||
| Zen 3 | 4 / 0.5FP0 FP1 | 11 / 0.5FP0 FP1 | ||
| Zen 4 | 4 / 0.5FP0 FP1 | 11 / 0.5FP0 FP1 | 4 / 0.5FP0 FP1 | 11 / 0.5FP0 FP1 |
| Jaguar | 3 / 1FPU0 FPU1 VALU0 VALU1 VIMUL | 8 / 1FPU0 FPU1 VALU0 VALU1 VIMUL | ||
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.
Every 128-bit block works alike: 1, 2 and 4 128-bit blocks in the xmm, ymm and zmm forms.
Result 128-bit block i comes from 128-bit block i of xmm2 and xmm3. Result 128-bit blocks: r0.
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
# the last round of the cipher, which leaves
# out MixColumns, in each 128-bit lane
for i in range(VL // 128):
s = sub_bytes(zmm2.dq[i]) # zmm2: the state
s = shift_rows(s)
zmm1.dq[i] = s ^ src3.dq[i] # AddRoundKey, the lane's key
# zmm1 is zeroed from bit VL upRun on AMD Zen 5 (EPYC 9645): 22 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
VAESENCLAST xmm, xmm, xmm/m128 VAESENCLAST ymm, ymm, ymm/m256 VAESENCLAST zmm, zmm, zmm/m512 | ||
xmm, ymm, zmm | explicit | write |
xmm, ymm, zmm | explicit | read |
xmm/m128, ymm/m256, zmm/m512 | 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.
- VEX forms
avx-type-4- EVEX forms
AVX512-E4
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to VAESENCLAST, 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_aesenclast_si128
__m128i _mm_aesenclast_si128(__m128i __V, __m128i __R) |
|
_mm256_aesenclast_epi128
__m256i _mm256_aesenclast_epi128(__m256i __A, __m256i __B) |
|
_mm512_aesenclast_epi128
__m512i _mm512_aesenclast_epi128(__m512i __A, __m512i __B) |
|
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 |
|---|---|---|
AVXAES | AES + 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 |
VAES | VAES | Ice Lake (client), Tiger Lake, Alder Lake, Arrow Lake, Panther Lake, Nova Lake, Ice Lake (server), Sapphire Rapids, Emerald Rapids, Granite Rapids, Diamond Rapids, Sierra Forest, Clearwater Forest, Zen 3, Zen 4, Zen 5, Zen 6 |
AVX512_VAES_128 | AVX10.1 + VAES or VAES + AES + AVX512F + AVX512VL XED and Intel’s SDM differ: XED also asks for the AES bit, Sources: Intel XED v2026.08.23, datafiles/gfni-vaes-vpcl/cpuid-evex.xed.txt; Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026), AESDEC, AESDECLAST, AESENC and AESENCLAST: the opcode tables, pages 3-33, 3-39, 3-45 and 3-51. | Ice Lake (client), Tiger Lake, Nova Lake, Ice Lake (server), Sapphire Rapids, Emerald Rapids, Granite Rapids, Diamond Rapids, Zen 4, Zen 5, Zen 6 |
AVX512_VAES_256 | Same as AVX512_VAES_128XED and Intel’s SDM differ: see the note on | Same as AVX512_VAES_128 |
AVX512_VAES_512 | AVX10.1 + VAES or VAES + AES + AVX512F XED and Intel’s SDM differ: see the note on | Same as AVX512_VAES_128 |
More AES-NI instructions
- AESDEC
- AESDECLAST
- AESENC
- AESENCLAST
- AESIMC
- AESKEYGENASSIST
- VAESDEC
- VAESDECLAST
- VAESENC
- VAESIMC
- VAESKEYGENASSIST
More VAES instructions
More AVX10.1 instructions
- KUNPCKBW
- KUNPCKDQ
- KUNPCKWD
- KXNORB
- KXNORD
- KXNORQ
- KXNORW
- KXORB
- KXORD
- KXORQ
- KXORW
- VADDPD
- VADDPH
- VADDPS
- VADDSD
- VADDSH
- VADDSS
- VAESDEC
- VAESDECLAST
- VAESENC
- VALIGND
- VALIGNQ
- VANDNPD
- VANDNPS
- VANDPD
- VANDPS
- VBLENDMPD
- VBLENDMPS
- VBROADCASTF32X2
- VBROADCASTF32X4
- VBROADCASTF32X8
- VBROADCASTF64X2
- VBROADCASTF64X4
- VBROADCASTI32X2
- VBROADCASTI32X4
- VBROADCASTI32X8
- VBROADCASTI64X2
- VBROADCASTI64X4
- VBROADCASTSD
- VBROADCASTSS
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 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2A, page 3-51 (AESENCLAST)
- Intel Advanced Vector Extensions 10.2 Architecture Specification, revision 7.0 (361050-007, April 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 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.