Extensions
Forms
2 (2 Legacy)
Data
Intel XED v2026.08.23

SHA1MSG2 finishes four words of SHA-1’s message schedule. FIPS 180-4 defines W[t] for t from 16 to 79 as the XOR of W[t-3], W[t-8], W[t-14] and W[t-16], rotated left by one bit. SHA1MSG1 and a PXOR leave the XOR of the last three in each dword of the first operand, W[t] in dword 3 down to W[t+3] in dword 0; SHA1MSG2 XORs in the W[t-3] terms, rotates, and writes W[t] to W[t+3] back in the same order.

The serial word

Three of the W[t-3] terms are old words, W[t-3], W[t-2] and W[t-1], which the second operand holds in dwords 2, 1 and 0; its dword 3 is not read. The fourth word, W[t+3], needs W[t], which the instruction has only just computed, so the hardware forms W[t] first and feeds it into the last dword. This dependency is why the schedule is split in two: everything before it is plain XORs that SHA1MSG1 and PXOR can do on all four dwords at once.

Two cases recorded on Zen 5 show the rotates. With a first operand of zeros and words of all ones, all four results were all ones. With a first operand of all ones and W[t-3] = 3B73215Eh, dword 3 became 8919BD43h, the complement of 3B73215Eh rotated left by one, and dword 0, built from that value, became EDCC8578h.

Fitting it in

The second operand is the newest of the four registers that hold the last sixteen words, so a schedule rotates through four registers and each step’s SHA1MSG2 reads the result of the step before. Each output then goes to SHA1NEXTE, which adds E to its first word for SHA1RNDS4. The legacy SSE form is the only one: it keeps bits 128 and up of the register, and a memory operand must be aligned to 16 bytes. The SHA-256 counterpart is SHA256MSG2. AMD’s Zen 5 guide lists SHA1MSG2 as microcoded.

In the optimization guide

What the optimization guide says about SHA1MSG2, a line per claim. Each links to the claim in the guide, with its sources and where they differ.

Silvermont to Goldmont Plus

Tremont

  • Vectors and cryptography: Intel improved the SHA extensions on Tremont: the round instructions run on port 20 and the message instructions on port 21, so the two can overlap.

Forms

Every encoding of SHA1MSG2 that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
SHA1MSG2 xmm, xmm SHA1MSG2_XMMi32_XMMi32_SHANP 0F 38 CA /rSHA
SHA1MSG2 xmm, m128 SHA1MSG2_XMMi32_MEMi32_SHANP 0F 38 CA /rSHA

Latency and throughput

What the scheduling models of LLVM 23.1.2 give for each form, not measurements: latency / reciprocal throughput in cycles, the ports under them. A row is a model, or models that agree; a dash, a form that its processors lack. Memory forms: latency from the address, ports without the load and store units. Which processors each model covers.
Modelxmm, xmmxmm, m128
Ice Lake5 / 0.5p0111 / 0.5p01
Alder Lake, Sapphire Rapids6 / 2p015613 / 2p0156
Lunar Lake6 / 1V0 V1 V2 V3 p0 p1 p2 p3 p4 p513 / 1V0 V1 V2 V3 p0 p1 p2 p3 p4 p5
Zen, Zen 21 / 0.5FPU1 FPU28 / 0.5FPU1 FPU2
Zen 3, Zen 41 / 0.5FP0 FP1 FP2 FP38 / 0.5FP0 FP1 FP2 FP3

Operation

What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.

# xmm1: W[i-16] ^ W[i-14] ^ W[i-8] for i
# from t to t + 3; src2: W[t-4] to W[t-1];
# the result: W[t] to W[t+3]
src1 = xmm1.read()
w = rol(src1.d[3] ^ src2.d[2], 1, 32)
xmm1.d[3] = w              # W[t]
for i in range(2, -1, -1):
    x = src2.d[i - 1] if i else w  # 3 words
    xmm1.d[i] = rol(src1.d[i] ^ x, 1, 32)
# bits 128 and up of the register are unchanged

Run on AMD Zen 5 (EPYC 9645): 4 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
SHA1MSG2 xmm, xmm/m128
xmmexplicitread, write
xmm/m128explicitread

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
SSE_TYPE_4

Attributes

What else XED records about the forms. How to read.

Memory forms
aligned memory operand

Intrinsics

The C intrinsics of Clang 23.1.2 that compile to SHA1MSG2, 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
_mm_sha1msg2_epu32 __m128i _mm_sha1msg2_epu32(__m128i __X, __m128i __Y)

SHA1MSG2 xmm, xmm Legacy -msha

SHA1MSG2 xmm, xmm Legacy -msha -mavxwith AVX enabled

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 SHA 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. LLVM 23.1.2's x86 scheduling models (commit 85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them.
  5. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2B, page 4-632 (SHA1MSG2)
  6. NIST FIPS 180-4: Secure Hash Standard (SHS) (August 2015)
  7. 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.