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

RDRAND fills a 16-, 32- or 64-bit register with a random number from the processor’s generator and sets CF to say whether it got one. On Intel’s processors the numbers come from a deterministic generator built to NIST SP 800-90A that an on-chip entropy source reseeds often; RDSEED reads closer to that entropy source, for seeding a generator of one’s own. AMD’s manual says only that the value is generated by hardware.

Always test CF

CF = 0 means no number was ready: the generator’s self-tests rejected its output, or many cores asked faster than it could supply. Both manuals tell software to try again a limited number of times, and Intel’s suggests ten; a program that loops forever on CF = 0 hangs on a failed generator. Every run clears OF, SF, ZF, AF and PF. Zen 5 set CF on each recorded run, with the other flags cleared.

The manuals differ on the failed value. Intel’s makes the destination 0; AMD’s only calls it invalid. Compiled code relies on Intel’s rule: for _rdrand32_step(&x), GCC 14 at -O2 emits rdrand eax and a CMOVC that puts 1 in EAX when CF is set, so when CF is clear the function returns the register itself, counting on it being 0; Clang 23 does the same with CMOVAE. Both store the register to x either way. Both need -mrdrnd or an -march that has it, such as ivybridge or znver1; x86-64-v3 and v4 do not.

Sizes

As with other general-purpose writes, the 32-bit form clears bits 63:32 and the 16-bit form leaves bits 63:16 alone: on Zen 5, rdrand r9w replaced only the low 16 bits of R9.

Cost and virtual machines

AMD’s Zen 5 guide lists RDRAND and RDSEED as microcoded, with no latency given. Under Intel’s VMX a hypervisor can make every RDRAND exit to it (“RDRAND exiting”, Intel’s manual, volume 3) and answer in its place. The CPUID bit is leaf 1, ECX bit 30.

In the optimization guide

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

Sandy Bridge and Ivy Bridge

  • What Ivy Bridge changed: Ivy Bridge adds three features: RDRAND, a hardware random number generator meeting NIST SP 800-90A; VCVTPH2PS and VCVTPS2PH, converting half-precision floats; and reading or writing the FS and GS base registers from any ring.

Silvermont to Goldmont Plus

Vulnerability mitigations

Mitigations of these processor vulnerabilities use RDRAND:

  • CVE-2022-21127: Special Register Buffer Data Sampling (Special Register Buffer Data Sampling update)
  • CVE-2020-0543: Special Register Buffer Data Sampling

Forms

Every encoding of RDRAND that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
RDRAND r16/32/64 RDRAND_GPRv0F C7 /6RDRAND

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.
Modelr16r32
r64
Sandy Bridge100 / 0.33p015100 / 0.33p015
Haswell1 / 5.33p012351 / 5.33p01235
Broadwell9 / 1p0123569 / 1p012356
Skylake, Skylake-SP, Ice Lake100 / 0.25p0156100 / 0.25p0156
Alder Lake, Sapphire Rapids1386 / 7p0 p1 p2 p3 p5 p6 p10 p11100 / 7p0 p1 p2 p3 p5 p6 p10 p11
Lunar Lake100 / 0.17p012345100 / 0.17p012345
Silvermont100 / 1FPC0100 / 1FPC0
Zen, Zen 2100 / 0.25100 / 0.25
Zen 3, Zen 4100 / 25ALU0 ALU1 ALU2 ALU3100 / 25ALU0 ALU1 ALU2 ALU3

Operation

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

ok = random_ready()              # the generator's: 1 when it has a
                                 # number for RDRAND, a random one
dest.write(random(OSIZE) if ok else 0)
cf = ok                          # 16 bits: bits 63:16 kept; 32 bits:
of = sf = zf = af = pf = 0       # bits 63:32 cleared
# with none ready, a program tries again, a few times. Intel's
# manual says that the destination is then 0, AMD's only that it is
# not valid. Intel's RDRAND draws from a deterministic generator that
# an entropy source on the chip reseeds

Run on AMD Zen 5 (EPYC 9645): 3 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
RDRAND r16/32/64
r16/32/64explicitwrite
RFLAGSimplicitwrite

Flags

M modified, 0 cleared; blank: not affected. How to read.
OFSFZFAFPFCF
All forms
00000M

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.

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. LLVM 23.1.2's x86 scheduling models (commit 85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them.
  4. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2B, page 4-554 (RDRAND)
  5. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
  6. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3 (325384-093, September 2026)
  7. AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
  8. 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 timings come from LLVM's scheduling models, part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.