Extensions
Forms
48 (12 Legacy, 36 EVEX)
Data
Intel XED v2026.08.23

ROL rotates its operand left: every bit moves up by the count, and the bits pushed out at the top come back in at the bottom, so none is lost. ROR rotates the other way, and a rotate left by k equals a rotate right by the operand’s width minus k. C has no rotate operator; GCC 14 and Clang 23 at -O2 recognize the pattern instead: (x << 7) | (x >> 25) on a uint32_t becomes rol eax, 7, and (x << 8) | (x >> 8) on a uint16_t, which swaps its two bytes, becomes rol ax, 8.

A count in a variable

(x << n) | (x >> (32 - n)) is undefined in C for n = 0, and (x << (n & 31)) | (x >> (-n & 31)) is not; both compilers turn either into one rol eax, cl, since the processor masks the count itself: to 5 bits, or 6 for a 64-bit operand. An 8- or 16-bit rotate then takes the masked count modulo its width, so rol al, cl with CL = 8 leaves AL as it was.

Only CF and OF

A rotate writes no flag but CF and OF. CF receives the bit that landed in bit 0, the last one to leave the top; OF is defined only for a count of 1. A masked count of 0 changes neither, but a count that is a multiple of the width is not 0: Zen 5, rotating a byte by 8 or a word by 16, left the value alone and still copied its bit 0 into CF. RCL and RCR rotate through CF instead.

Other forms and speed

RORX from BMI2 rotates right by an immediate into another register and leaves the flags alone; with -march=x86-64-v3, both compilers use it for constant rotates either way, turning the rotate left by 7 into rorx eax, edi, 25. APX adds forms with a new destination and forms that leave the flags unchanged (NF).

Intel’s optimization manual says that in Sandy Bridge a rotate by CL takes three micro-ops, one of which may be dropped when no later instruction reads its flags (Section 3.5.1.5). The instruction table of AMD’s Zen 5 guide lists ROL and ROR as single macro-ops with a latency of one cycle.

In the optimization guide

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

Out of order

  • Partial register and flag writes: A shift or rotate by CL leaves the flags alone when the count is zero, which is known only when it runs, so it depends on the old flags too.

Forms

Every encoding of ROL that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
ROL m8, imm8 ROL_MEMb_IMMbC0 /0 ibBase instruction set
ROL r8, imm8 ROL_GPR8_IMMbC0 /0 ibBase instruction set
ROL m16/32/64, imm8 ROL_MEMv_IMMbC1 /0 ibBase instruction set
ROL r16/32/64, imm8 ROL_GPRv_IMMbC1 /0 ibBase instruction set
ROL m8, 1 ROL_MEMb_ONED0 /0Base instruction set
ROL r8, 1 ROL_GPR8_ONED0 /0Base instruction set
ROL m16/32/64, 1 ROL_MEMv_ONED1 /0Base instruction set
ROL r16/32/64, 1 ROL_GPRv_ONED1 /0Base instruction set
ROL m8, CL ROL_MEMb_CLD2 /0Base instruction set
ROL r8, CL ROL_GPR8_CLD2 /0Base instruction set
ROL m16/32/64, CL ROL_MEMv_CLD3 /0Base instruction set
ROL r16/32/64, CL ROL_GPRv_CLD3 /0Base instruction set
ROL r8, imm8 ROL_GPR8i8_IMM8_APXEVEX.LLZ.NP.MAP4.WIG C0 /0 ibAPX_F
ROL m8, imm8 ROL_MEMi8_IMM8_APXEVEX.LLZ.NP.MAP4.WIG C0 /0 ibAPX_F
ROL r8, imm8 NF ROL_GPR8i8_IMM8_APX_N3EVEX.LLZ.NP.MAP4.WIG C0 /0 ib NF=1APX_F + APX_NCI_NDD_NF
ROL m8, imm8 NF ROL_MEMi8_IMM8_APX_N3EVEX.LLZ.NP.MAP4.WIG C0 /0 ib NF=1APX_F + APX_NCI_NDD_NF
ROL r16/32/64, r16/32/64, imm8 NDD NF optional ROL_GPRv_GPRv_IMM8_APX_N3EVEX.LLZ.NP.MAP4.SCALABLE C1 /0 ib ND=1 NF=0/1APX_F + APX_NCI_NDD_NF
ROL r16/32/64, m16/32/64, imm8 NDD NF optional ROL_GPRv_MEMv_IMM8_APX_N3EVEX.LLZ.NP.MAP4.SCALABLE C1 /0 ib ND=1 NF=0/1APX_F + APX_NCI_NDD_NF
ROL r8, 1 ROL_GPR8i8_ONE_APXEVEX.LLZ.NP.MAP4.WIG D0 /0APX_F
ROL m8, 1 ROL_MEMi8_ONE_APXEVEX.LLZ.NP.MAP4.WIG D0 /0APX_F
ROL r8, 1 NF ROL_GPR8i8_ONE_APX_N3EVEX.LLZ.NP.MAP4.WIG D0 /0 NF=1APX_F + APX_NCI_NDD_NF
ROL m8, 1 NF ROL_MEMi8_ONE_APX_N3EVEX.LLZ.NP.MAP4.WIG D0 /0 NF=1APX_F + APX_NCI_NDD_NF
ROL r8, r8, 1 NDD NF optional ROL_GPR8i8_GPR8i8_ONE_APX_N3EVEX.LLZ.NP.MAP4.WIG D0 /0 ND=1 NF=0/1APX_F + APX_NCI_NDD_NF
ROL r8, m8, 1 NDD NF optional ROL_GPR8i8_MEMi8_ONE_APX_N3EVEX.LLZ.NP.MAP4.WIG D0 /0 ND=1 NF=0/1APX_F + APX_NCI_NDD_NF
ROL r16/32/64, 1 ROL_GPRv_ONE_APXEVEX.LLZ.NP.MAP4.SCALABLE D1 /0APX_F
ROL m16/32/64, 1 ROL_MEMv_ONE_APXEVEX.LLZ.NP.MAP4.SCALABLE D1 /0APX_F
ROL r16/32/64, 1 NF ROL_GPRv_ONE_APX_N3EVEX.LLZ.NP.MAP4.SCALABLE D1 /0 NF=1APX_F + APX_NCI_NDD_NF
ROL m16/32/64, 1 NF ROL_MEMv_ONE_APX_N3EVEX.LLZ.NP.MAP4.SCALABLE D1 /0 NF=1APX_F + APX_NCI_NDD_NF
ROL r16/32/64, r16/32/64, 1 NDD NF optional ROL_GPRv_GPRv_ONE_APX_N3EVEX.LLZ.NP.MAP4.SCALABLE D1 /0 ND=1 NF=0/1APX_F + APX_NCI_NDD_NF
ROL r16/32/64, m16/32/64, 1 NDD NF optional ROL_GPRv_MEMv_ONE_APX_N3EVEX.LLZ.NP.MAP4.SCALABLE D1 /0 ND=1 NF=0/1APX_F + APX_NCI_NDD_NF
ROL r8, CL ROL_GPR8i8_CL_APXEVEX.LLZ.NP.MAP4.WIG D2 /0APX_F
ROL m8, CL ROL_MEMi8_CL_APXEVEX.LLZ.NP.MAP4.WIG D2 /0APX_F
ROL r8, CL NF ROL_GPR8i8_CL_APX_N3EVEX.LLZ.NP.MAP4.WIG D2 /0 NF=1APX_F + APX_NCI_NDD_NF
ROL m8, CL NF ROL_MEMi8_CL_APX_N3EVEX.LLZ.NP.MAP4.WIG D2 /0 NF=1APX_F + APX_NCI_NDD_NF
ROL r8, r8, CL NDD NF optional ROL_GPR8i8_GPR8i8_CL_APX_N3EVEX.LLZ.NP.MAP4.WIG D2 /0 ND=1 NF=0/1APX_F + APX_NCI_NDD_NF
ROL r8, m8, CL NDD NF optional ROL_GPR8i8_MEMi8_CL_APX_N3EVEX.LLZ.NP.MAP4.WIG D2 /0 ND=1 NF=0/1APX_F + APX_NCI_NDD_NF
ROL r16/32/64, CL ROL_GPRv_CL_APXEVEX.LLZ.NP.MAP4.SCALABLE D3 /0APX_F
ROL m16/32/64, CL ROL_MEMv_CL_APXEVEX.LLZ.NP.MAP4.SCALABLE D3 /0APX_F
ROL r16/32/64, CL NF ROL_GPRv_CL_APX_N3EVEX.LLZ.NP.MAP4.SCALABLE D3 /0 NF=1APX_F + APX_NCI_NDD_NF
ROL m16/32/64, CL NF ROL_MEMv_CL_APX_N3EVEX.LLZ.NP.MAP4.SCALABLE D3 /0 NF=1APX_F + APX_NCI_NDD_NF
ROL r16/32/64, r16/32/64, CL NDD NF optional ROL_GPRv_GPRv_CL_APX_N3EVEX.LLZ.NP.MAP4.SCALABLE D3 /0 ND=1 NF=0/1APX_F + APX_NCI_NDD_NF
ROL r16/32/64, m16/32/64, CL NDD NF optional ROL_GPRv_MEMv_CL_APX_N3EVEX.LLZ.NP.MAP4.SCALABLE D3 /0 ND=1 NF=0/1APX_F + APX_NCI_NDD_NF
ROL r8, r8, imm8 NDD NF optional ROL_GPR8i8_GPR8i8_IMM8_APX_N3EVEX.LLZ.NP.MAP4.WIG C0 /0 ib ND=1 NF=0/1APX_F + APX_NCI_NDD_NF
ROL r8, m8, imm8 NDD NF optional ROL_GPR8i8_MEMi8_IMM8_APX_N3EVEX.LLZ.NP.MAP4.WIG C0 /0 ib ND=1 NF=0/1APX_F + APX_NCI_NDD_NF
ROL r16/32/64, imm8 ROL_GPRv_IMM8_APXEVEX.LLZ.NP.MAP4.SCALABLE C1 /0 ibAPX_F
ROL m16/32/64, imm8 ROL_MEMv_IMM8_APXEVEX.LLZ.NP.MAP4.SCALABLE C1 /0 ibAPX_F
ROL r16/32/64, imm8 NF ROL_GPRv_IMM8_APX_N3EVEX.LLZ.NP.MAP4.SCALABLE C1 /0 ib NF=1APX_F + APX_NCI_NDD_NF
ROL m16/32/64, imm8 NF ROL_MEMv_IMM8_APX_N3EVEX.LLZ.NP.MAP4.SCALABLE C1 /0 ib NF=1APX_F + APX_NCI_NDD_NF

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.
Modelm8, imm8
m8, 1
r8, imm8
r16, imm8
r32, imm8
r64, imm8
m16, imm8
m32, imm8
m64, imm8
m16, 1
m32, 1
m64, 1
r8, 1
r16, 1
r32, 1
r64, 1
m8, CLr8, CL
r16, CL
r32, CL
r64, CL
m16, CL
m32, CL
m64, CL
Sandy Bridge8 / 1p052 / 1p058 / 1p052 / 1p059 / 1.5p053 / 1.5p059 / 1.5p05
Haswell8 / 1p061 / 0.5p068 / 1p062 / 1p069 / 1p01563 / 1.5p069 / 1p0156
Broadwell7 / 1p061 / 0.5p067 / 1p062 / 1p068 / 1p01563 / 1.5p068 / 1p0156
Skylake, Skylake-SP, Ice Lake7 / 1p061 / 0.5p067 / 1p062 / 1p068 / 1.5p063 / 1.5p068 / 1.5p06
Alder Lake, Sapphire Rapids13 / 1p061 / 1p0612 / 1p061 / 1p0613 / 1p062 / 1p0612 / 1p06
Lunar Lake13 / 0.67p0241 / 0.67p02412 / 0.67p0241 / 0.67p02413 / 0.67p0242 / 0.67p13512 / 0.67p024
Bonnell1 / 1p01 / 1p01 / 1p01 / 1p01 / 1p01 / 1p01 / 1p0
Silvermont4 / 2IEC0 MEC1 / 1IEC04 / 2IEC0 MEC1 / 1IEC04 / 2IEC0 MEC1 / 1IEC04 / 2IEC0 MEC
Piledriver5 / 2EX0 EX11 / 1EX0 EX15 / 2EX0 EX11 / 1EX0 EX15 / 2EX0 EX11 / 0.5EX0 EX15 / 2EX0 EX1
Zen5 / 1ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU35 / 1ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU35 / 1ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU35 / 1ALU0 ALU1 ALU2 ALU3
Zen 25 / 0.67ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU35 / 0.67ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU35 / 0.67ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU35 / 0.67ALU0 ALU1 ALU2 ALU3
Zen 3, Zen 45 / 0.67ALU1 ALU21 / 0.5ALU1 ALU25 / 0.67ALU1 ALU21 / 0.5ALU1 ALU25 / 0.67ALU1 ALU21 / 0.5ALU1 ALU25 / 0.67ALU1 ALU2
Jaguar4 / 1ALU0 ALU11 / 0.5ALU0 ALU14 / 1ALU0 ALU11 / 0.5ALU0 ALU14 / 1ALU0 ALU11 / 0.5ALU0 ALU14 / 1ALU0 ALU1

Operation

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

All forms but the NDD forms
a = dest.read()
n = count & (0x3F if OSIZE == 64 else 0x1F)   # the count is masked,
k = n % OSIZE                    # then taken modulo the operand size
r = low(a << k | a >> (OSIZE - k))
if n != 0 and not nf:            # a count of 0 changes no flag; NF=1
                                 # (APX) none at all
    cf = r & 1                   # the bit rotated into bit 0, even
                                 # when k is 0
    flip = msb(r) ^ (r & 1)
    of = flip if n == 1 else UNDEFINED   # the top bit and CF differ
dest.write(r)                    # even for a count of 0, a 32-bit register
                                 # gets bits 63:32 cleared

Run on AMD Zen 5 (EPYC 9645): 225 cases. The APX forms were not run: none of these processors has APX.

NDD forms
a = src.read()
n = count & (0x3F if OSIZE == 64 else 0x1F)   # the count is masked,
k = n % OSIZE                    # then taken modulo the operand size
r = low(a << k | a >> (OSIZE - k))
if n != 0 and not nf:            # a count of 0 changes no flag; NF=1
                                 # none at all
    cf = r & 1                   # the bit rotated into bit 0, even
                                 # when k is 0
    flip = msb(r) ^ (r & 1)
    of = flip if n == 1 else UNDEFINED   # the top bit and CF differ
dest.write(r)                    # the new destination: bits 63:OSIZE
                                 # cleared, even for 8 and 16 bits

Not run on a processor: none of these processors has APX.

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
ROL r/m8, imm8 ROL r/m16/32/64, imm8
r/m8/16/32/64explicitread, write
imm8explicitread
RFLAGSimplicitwrite
ROL r/m8, 1 ROL r/m16/32/64, 1
r/m8/16/32/64explicitread, write
1explicitread
RFLAGSimplicitwrite
ROL r/m8, CL ROL r/m16/32/64, CL
r/m8/16/32/64explicitread, write
CLexplicitread
RFLAGSimplicitconditional write
ROL r/m8, imm8 NF ROL r/m16/32/64, imm8 NF
r/m8/16/32/64explicitread, write
imm8explicitread
ROL r8, r/m8, imm8 NDD NF optional ROL r16/32/64, r/m16/32/64, imm8 NDD NF optional
r8/16/32/64explicitwrite
r/m8/16/32/64explicitread
imm8explicitread
RFLAGSimplicitwrite (NF=0)
ROL r/m8, 1 NF ROL r/m16/32/64, 1 NF
r/m8/16/32/64explicitread, write
1explicitread
ROL r8, r/m8, 1 NDD NF optional ROL r16/32/64, r/m16/32/64, 1 NDD NF optional
r8/16/32/64explicitwrite
r/m8/16/32/64explicitread
1explicitread
RFLAGSimplicitwrite (NF=0)
ROL r/m8, CL NF ROL r/m16/32/64, CL NF
r/m8/16/32/64explicitread, write
CLexplicitread
ROL r8, r/m8, CL NDD NF optional ROL r16/32/64, r/m16/32/64, CL NDD NF optional
r8/16/32/64explicitwrite
r/m8/16/32/64explicitread
CLexplicitread
RFLAGSimplicitconditional write (NF=0)

Flags

M modified, U undefined; blank: not affected. With NF=1, the forms with optional NF leave the flags unchanged. How to read.
WhenOFCF
ROL r/m8, imm8 ROL r/m16/32/64, imm8
count 1MM
count 2 or moreUM
ROL r/m8, 1 ROL r/m16/32/64, 1
MM
ROL r/m8, CL ROL r/m16/32/64, CL
in some casesUM
NF forms
Not affected
ROL r8, r/m8, imm8 NDD NF optional ROL r16/32/64, r/m16/32/64, imm8 NDD NF optional
NF=0, count 1MM
NF=0, count 2 or moreUM
ROL r8, r/m8, 1 NDD NF optional ROL r16/32/64, r/m16/32/64, 1 NDD NF optional
NF=0MM
ROL r8, r/m8, CL NDD NF optional ROL r16/32/64, r/m16/32/64, CL NDD NF optional
NF=0, in some casesUM

Exceptions

The exception class is XED's name for the set of exception conditions that a form follows. How to read.

Legacy forms
none in XED
EVEX forms
APX-EVEX-INT

Intrinsics

The C intrinsics of Clang 23.1.2 that compile to ROL, 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
_lrotl unsigned long long _lrotl(unsigned long long a, int b)

ROL r16/32/64, CL Legacy

__rolb unsigned char __rolb(unsigned char __X, int __C)

ROL r8, CL Legacy

__rold unsigned int __rold(unsigned int __X, int __C)

ROL r16/32/64, CL Legacy

__rolq unsigned long long __rolq(unsigned long long __X, int __C)

ROL r16/32/64, CL Legacy

__rolw unsigned short __rolw(unsigned short __X, int __C)

ROL r16/32/64, CL Legacy

_rotl unsigned int _rotl(unsigned int a, int b)

ROL r16/32/64, CL Legacy

_rotwl unsigned short _rotwl(unsigned short a, int b)

ROL r16/32/64, CL Legacy

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.
ISA setCPUIDProcessors
I186

No CPUID bit: part of the base instruction set.

Every x86-64 processor in XED’s model and Zen 3 to Zen 6
I86

No CPUID bit: part of the base instruction set.

Every x86-64 processor in XED’s model and Zen 3 to Zen 6
APX_F

APX_F
CPUID.(EAX=07H,ECX=1):EDX[21] APX_F

Nova Lake, Diamond Rapids
APX_F_N3

APX_F + APX_NCI_NDD_NF
CPUID.(EAX=07H,ECX=1):EDX[21] APX_F
CPUID.(EAX=29H,ECX=0):EBX[0] APX_NCI_NDD_NF

Same as APX_F

More General-purpose instructions

All 109 General-purpose instructions

More APX instructions

All 88 APX 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-533 (RCL/RCR/ROL/ROR)
  6. Intel Advanced Performance Extensions (Intel APX) Architecture Specification, revision 9.0 (355828-009, August 2026)
  7. AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
  8. Intel 64 and IA-32 Architectures Optimization Reference Manual, Volume 1 (248966-051, October 2026)
  9. 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.