CPOP

Population Count

CPOP rd, rs1

Counts the number of set bits (1s) in the register.

Details

CPOP counts the number of set bits (population count / Hamming weight) in rs1 and writes the count to rd.

Pseudocode Operation

R[rd] = count_set_bits(R[rs1]);

Example

CPOP x10, x11

Encoding

Binary Layout
0110000
31:25
00010
24:20
rs1
19:15
001
14:12
rd
11:7
0010011
6:0
 
Format I-Type
Opcode 0x13
Extension Zbb

Operands

  • rd
    Destination register (integer)
  • rs1
    Source