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

SHA1RNDS4 runs four of the 80 rounds of SHA-1’s compression function (FIPS 180-4). The first operand holds the working variables A, B, C and D, A in dword 3 down to D in dword 0, and receives them after the four rounds. The second holds the message words for those rounds, W[t] in dword 3 to W[t+3] in dword 0, with the fifth variable, E, already added to W[t]. Bits 1:0 of the immediate pick the round group, and with it the function and the constant of FIPS 180-4:

imm8roundsfunctionconstant
00 to 19Ch5A827999H
120 to 39Parity6ED9EBA1H
240 to 59Maj8F1BBCDCH
360 to 79ParityCA62C1D6H

A block therefore takes 20 SHA1RNDS4s, five with each immediate. Zen 5 ignored bits 7:2: its recorded cases with FEH, 83H and E9H ran as 2, 3 and 1. GCC 14 and Clang 23 reject any _mm_sha1rnds4_epu32 immediate above 3, and a variable one, at compile time (-msha).

Where E comes from

SHA-1 keeps five variables, but the register holds four. After four rounds the new E is the old A rotated left by 30, so the program keeps a copy of the state before each SHA1RNDS4, and SHA1NEXTE turns that copy’s A into the E of the next four rounds and adds it to their first message word: GCC 14 and Clang 23 at -O2 compile the pair to sha1nexte and sha1rnds4. For the first four rounds of a block, E is the fifth word of the hash value, added with PADDD; at the end of the block, SHA1NEXTE also forms the final E, and a PADDD adds A to D back to the hash value.

The message schedule

FIPS 180-4 extends a block’s 16 words to 80, each the XOR of four earlier ones rotated left by 1. SHA1MSG1, a PXOR and SHA1MSG2 compute four at a time, and the 16 words of a block are byte-swapped first with PSHUFB, since SHA-1 reads them big-endian.

Like SHA256RNDS2, its SHA-256 counterpart, SHA1RNDS4 has no VEX form and keeps bits 128 and up of its destination. AMD’s Zen 5 guide lists it, and SHA1NEXTE and the message instructions, as microcoded.

In the optimization guide

What the optimization guide says about SHA1RNDS4, 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 SHA1RNDS4 that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
SHA1RNDS4 xmm, xmm, imm8 SHA1RNDS4_XMMi32_XMMi32_IMM8_SHANP 0F 3A CC /r ibSHA
SHA1RNDS4 xmm, m128, imm8 SHA1RNDS4_XMMi32_MEMi32_IMM8_SHANP 0F 3A CC /r ibSHA

Operation

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

f = imm8 & 3               # rounds 20f to
if f == 0:                 # 20f + 19, and
    k = 0x5A827999         # their constant
elif f == 1:
    k = 0x6ED9EBA1
elif f == 2:
    k = 0x8F1BBCDC
else:
    k = 0xCA62C1D6
a = xmm1.d[3]              # the state
b = xmm1.d[2]
c = xmm1.d[1]
d = xmm1.d[0]
e = 0                      # in src2.d[3]
for i in range(4):
    if f == 0:
        x = choose(b, c, d)
    elif f == 2:
        x = majority(b, c, d)
    else:
        x = b ^ c ^ d      # parity
    t = rol(a, 5, 32) + x + e + k
    e = d
    d = c
    c = rol(b, 30, 32)
    b = a
    a = low(t + src2.d[3 - i], 32)  # W
xmm1.d[3] = a
xmm1.d[2] = b
xmm1.d[1] = c
xmm1.d[0] = d
# bits 128 and up of the register are unchanged

Run on AMD Zen 5 (EPYC 9645): 5 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
SHA1RNDS4 xmm, xmm/m128, imm8
xmmexplicitread, write
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
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 SHA1RNDS4, 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_sha1rnds4_epu32 __m128i _mm_sha1rnds4_epu32(__m128i V1, __m128i V2, const int M)

SHA1RNDS4 xmm, xmm, imm8 Legacy -msha

SHA1RNDS4 xmm, xmm, imm8 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. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2B, page 4-634 (SHA1RNDS4)
  5. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
  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, part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.