popcntd

Population Count Doubleword

popcntd RA, RS

Counts the number of set bits (1s) in a 64-bit register.

Details

The popcntd instruction counts the number of one bits in each doubleword (64-bit) of register RS and places the result into the corresponding doubleword of register RA. The count ranges from 0 to 64, inclusive.

Pseudocode Operation

RA <- CountOnes(RS)

Programming Note

The popcntd instruction is useful for counting the number of set bits (1s) in a 64-bit value. It operates on each doubleword independently, so if you're working with 128-bit values, ensure that both halves are processed separately. This instruction does not require any special alignment and can be executed at user privilege level. Be cautious when using this instruction in performance-critical sections, as it may have varying execution times depending on the input data.

Example

popcntd r3, r4

Encoding

Binary Layout
31
0
RS
6
RA
11
00000
16
506
21
/
31
 
Format X-form
Opcode 0x7C0003F4
Extension Base

Operands

  • RA
    Target Register
  • RS
    Source Register