Extensions
Forms
8 (4 VEX, 4 EVEX)
Data
Intel XED v2026.08.23

SARX shifts its source right arithmetically, copying the sign bit into the vacated bits, by a count taken from any register, and writes the result to a third register without touching the flags. The source may be in memory: sarx eax, [rdi], ecx shifts the doubleword at RDI right by ECX. It does what SAR does with a count in CL, including its rounding toward minus infinity for negative values; SHLX and SHRX are its siblings for the other shifts, and RORX the rotate.

The count

As with SAR, only the low 5 bits of the count register count, or 6 bits for a 64-bit operand. A count of 32 on a 32-bit operand is therefore a count of 0 and leaves the value as it was, rather than filling it with copies of the sign. C leaves x >> 32 undefined, so compilers rely on the masking: with -march=x86-64-v3, GCC 14 and Clang 23 at -O2 compile both x >> n and x >> (n & 31) on an int to the same single sarx eax, edi, esi.

SARX has no immediate form, so a shift by a constant remains sar rax, 7.

Why without flags

A shift by CL that happens to be 0 leaves the flags as they were, so the processor must keep the old flags around for it. Intel’s optimization manual says that in Sandy Bridge SHL reg, cl and its kin take three micro-ops, one of which may be dropped only when no later instruction reads the flags (Section 3.5.1.5). SARX has no such link to the flags, needs no move of the count into CL, and keeps its source, so a loop can shift the same value by several counts.

The instruction table of AMD’s Zen 5 guide lists SARX, like SAR, as one macro-op with a latency of one cycle; Intel’s manual places it with the shifts and rotates on the shift units of Golden Cove (Table 2-4).

SARX belongs to BMI2, part of x86-64-v3; APX adds an EVEX form that reaches its new registers.

Forms

Every encoding of SARX that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
SARX r32, m32, r32 SARX_GPR32d_MEMd_GPR32dVEX.LZ.F3.0F38.W0 F7 /rBMI2
SARX r32, r32, r32 SARX_GPR32d_GPR32d_GPR32dVEX.LZ.F3.0F38.W0 F7 /rBMI2
SARX r64, m64, r64 64-bit mode only SARX_GPR64q_MEMq_GPR64qVEX.LZ.F3.0F38.W1 F7 /rBMI2
SARX r64, r64, r64 64-bit mode only SARX_GPR64q_GPR64q_GPR64qVEX.LZ.F3.0F38.W1 F7 /rBMI2
SARX r32, r32, r32 SARX_GPR32i32_GPR32i32_GPR32i32_APXEVEX.LLZ.F3.0F38.W0 F7 /rAPX_F + BMI2
SARX r32, m32, r32 SARX_GPR32i32_MEMi32_GPR32i32_APXEVEX.LLZ.F3.0F38.W0 F7 /rAPX_F + BMI2
SARX r64, r64, r64 SARX_GPR64i64_GPR64i64_GPR64i64_APXEVEX.LLZ.F3.0F38.W1 F7 /rAPX_F + BMI2
SARX r64, m64, r64 SARX_GPR64i64_MEMi64_GPR64i64_APXEVEX.LLZ.F3.0F38.W1 F7 /rAPX_F + BMI2

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.
Modelr32, m32, r32
r64, m64, r64
r32, r32, r32
r64, r64, r64
Haswell, Broadwell, Skylake, Skylake-SP, Ice Lake6 / 0.5p061 / 0.5p06
Alder Lake, Sapphire Rapids8 / 0.5p063 / 0.5p06
Lunar Lake8 / 0.33p0243 / 0.33p024
Zen5 / 0.5ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU3
Zen 25 / 0.33ALU0 ALU1 ALU2 ALU31 / 0.25ALU0 ALU1 ALU2 ALU3
Zen 3, Zen 45 / 0.5ALU1 ALU21 / 0.5ALU1 ALU2

Operation

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

n = count & (0x3F if OSIZE == 64 else 0x1F)   # the count is masked
dest.write(signed(src) >> n)     # copies of the sign bit come in; no flag
                                 # changes, whatever the count

Run on AMD Zen 5 (EPYC 9645): 45 cases. The APX forms were not run: 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
SARX r32, r/m32, r32 SARX r64, r/m64, r64 64-bit mode only
r32/64explicitwrite
r/m32/64explicitread
r32/64explicitread

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
none in XED
EVEX forms
APX-EVEX-BMI

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 BMI2 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. 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-609 (SARX/SHLX/SHRX)
  5. Intel Advanced Performance Extensions (Intel APX) Architecture Specification, revision 9.0 (355828-009, August 2026)
  6. AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
  7. Intel 64 and IA-32 Architectures Optimization Reference Manual, Volume 1 (248966-051, 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.