Encoding:

MSA

011110

11000001

df

ws

wd

2R

011110

6

8

2

5

5

6

Format:

PCNT.df 

Vector Population Count

PCNT.B wd,ws

MSA

Vector Population Count

PCNT.H wd,ws

MSA

Vector Population Count

PCNT.W wd,ws

MSA

Vector Population Count

PCNT.D wd,ws

MSA

Vector Population Count

Purpose:

Vector Population Count

Vector element count of all bits set to 1.

Description:

wd[i] = population_count(ws[i])

The number of bits set to 1 for elements in vector ws is stored to the elements in vector wd.

The operands and results are values in integer data format df.

Restrictions:

No data-dependent exceptions are possible.

Operation:

PCNT.B
   for i in 0 .. WRLEN/8-1
      WR[wd]8i+7..8i = population_count(WR[ws]8i+7..8i, 8)
   endfor
PCNT.H
   for i in 0 .. WRLEN/16-1
      WR[wd]16i+15..16i = population_count(WR[ws]16i+15..16i, 16)
   endfor
PCNT.W
   for i in 0 .. WRLEN/32-1
      WR[wd]32i+31..32i = population_count(WR[ws]32i+31..32i, 32)
   endfor
PCNT.D
   for i in 0 .. WRLEN/64-1
      WR[wd]64i+63..64i = population_count(WR[ws]64i+63..64i, 64)
   endfor
function population_count(tt, n)
   z = 0
   for i in n-1..0
      if tti = 1 then
          z = z + 1
      endif
endfunction population_count

Exceptions:

Reserved Instruction Exception, MSA Disabled Exception.