Home/Instructions/Carry-Less Multiply High
CLMULH

RISC-V CLMULH Instruction Details

Instruction ManualR-type

RV32/RV64 Zbc/Zbkc carry-less multiply, returning high XLEN bits of the 2*XLEN-bit product.

Instruction Syntax

clmulh rd, rs1, rs2

RV32/RV64 Zbc or Zbkc 1.0; syntax clmulh rd, rs1, rs2, with no rs3 or immediate.

32-bit R-type: funct7=0000101, funct3=011, opcode=0110011; register fields select x0–x31.

Select shifted rs1 terms with set rs2 bits and combine with XOR; select full-product bits 2*XLEN-1:XLEN. Sources use old XLEN-bit patterns; x0 reads zero and discards writes.

ZbcZbkcBit ManipulationCrypto

Instruction Behavior

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

CLMULH Decode & Execute Animation

This model shows ISA-visible GF(2) XOR partial products; it does not model integer carries, a pipeline, or a cryptographic protocol.

Execution context
32-bit encoding fields
31..25
funct7
0000101
24..20
rs2
01100
19..15
rs1
01011
14..12
funct3
011
11..7
rd
01010
6..0
opcode
0110011
Execution data path

funct7=0000101, funct3=011

x10 <- pending

Quick Understanding & Search Notes

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

RV32/RV64: Zbc/Zbkc 1.0; read two XLEN-bit integer-register patterns and combine partial products with XOR.
Select high XLEN bits from the full 2*XLEN-bit carry-less product, without polynomial modular reduction.
x0 reads as zero and discards writes; overlapping source and destination registers use the pre-writeback sources.

Common Usage Scenarios

Bit Manipulation

RV32 Zbc/Zbkc, x11=0x80000000 and x12=2: full carry-less product=0x0000000100000000; clmulh writes x10=1.

Pre-Use Checklist

Syntax Check
  • RV32/RV64 Zbc or Zbkc 1.0; syntax clmulh rd, rs1, rs2, with no rs3 or immediate.
  • 32-bit R-type: funct7=0000101, funct3=011, opcode=0110011; register fields select x0–x31.
Semantic Check
  • Select shifted rs1 terms with set rs2 bits and combine with XOR; select full-product bits 2*XLEN-1:XLEN. Sources use old XLEN-bit patterns; x0 reads zero and discards writes.

Pitfalls / Common Confusions

MULH/MULHU select integer-product high bits; clmulh selects high bits of the carry-less product formed with XOR partial products.

FAQ

Does clmulh access memory?

It does not access data memory. It reads two integer registers and delivers the selected product bits to rd; rd=x0 discards the result.

Does clmulh interpret signed numbers?

It treats XLEN-bit patterns as polynomial operands for carry-less multiplication, without signed-integer multiplication semantics; partial products combine with XOR.