Home/Instructions/Carry-Less Multiply High
CLMULH

RISC-V CLMULH Instruction Details

Instruction ManualR-type

Carry-less multiply (high-part)

Instruction Syntax

clmulh rd, rs1, rs2
Operand Breakdown
Destination rd: register receiving the operation result.
Source rs1: register holding the first operand.
Source rs2: register holding the second operand.
BZbcBit ManipulationCrypto

Instruction Encoding

31..25
funct7
24..20
rs2
19..15
rs1
14..12
funct3
11..7
rd
6..0
opcode

CLMULH uses opcode 0110011 (0x33), funct3 011, funct7 0000101. The rs1 and rs2 fields select the two source registers, and rd selects the destination register.

Format: R-type
opcode: 0110011 (0x33)
funct3: 011 (0x3)
funct7: 0000101 (0x05)

Instruction Behavior

clmulh performs GF(2) carry-less multiplication and returns the high XLEN bits.

Quick Understanding & Search Notes

clmulh performs GF(2) carry-less multiplication and returns the high XLEN bits.

These instructions are part of a B-extension subset and operate on XLEN-wide integer register values.
The high-half selection is distinct from signed or unsigned integer MULH semantics.

Common Usage Scenarios

Crypto & Security

Understand this scenario with real code like «clmulh x10, x11, x12 ; x10 = high_half(clmul(x11, x12))».

Multiplication & Division

Understand this scenario with real code like «clmulh x10, x11, x12 ; x10 = high_half(clmul(x11, x12))».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is R-type.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

Pitfalls / Common Confusions

The high-half selection is distinct from signed or unsigned integer MULH semantics.

FAQ

Does clmulh access memory?

No. It reads integer register operands and writes rd only.

Does clmulh interpret signed numbers?

These bit operations work on bit patterns directly; aside from the specified word-width selection, arithmetic signed magnitude is not used.