3 .c 0 1 1 2 1 2 2 3 1 2 2 3 2 3 3 4 1 2 2 3 2 3 3 4 2 3 3 4 3 4 4 5 1 2 2 3 2 3 3 4 2 3 3 4 3 4 4 5 2 3 3 4 3 4 4 5 3 4 4 5 4 5 5 6 1 2 2 3 2 3 3 4 2 3 3 4 3 4 4 5 2 3 3 4 3 4 4 5 3 4 4 5 4 5 5 6 2 3 3 4 3 4 4 5 3 4 4 5 4 5 5 6 3 4 4 5 4 5 5 6 4 5 5 6 5 6 6 7 1 2 2 3 2 3 3 4 2 3 3 4 3 4 4 5 2 3 3 4 3 4 4 5 3 4 4 5 4 5 5 6 2 3 3 4 3 4 4 5 3 4 4 5 4 5 5 6 3 4 4 5 4 5 5 6 4 5 5 6 5 6 6 7 2 3 3 4 3 4 4 5 3 4 4 5 4 5 5 6 3 4 4 5 4 5 5 6 4 5 5 6 5 6 6 7 3 4 4 5 4 5 5 6 4 5 5 6 5 6 6 7 4 5 5 6 5 6 6 7 5 6 6 7 6 7 7 8
13 #define BIT2(OP, ARG, RES, R0, R1) \
16 beqi OP##R0##R1##ARG %R0 RES \
20 #define BIT1(OP, ARG, RES, V0, V1, V2, R0, R1, R2) \
21 BIT2(OP, ARG, RES, V0, V0) \
22 BIT2(OP, ARG, RES, V0, V1) \
23 BIT2(OP, ARG, RES, V0, V2) \
24 BIT2(OP, ARG, RES, V0, R0) \
25 BIT2(OP, ARG, RES, V0, R1) \
26 BIT2(OP, ARG, RES, V0, R2)
28 #define BIT(OP, ARG, RES, V0, V1, V2, R0, R1, R2) \
29 BIT1(OP, ARG, RES, V1, V2, R0, R1, R2, V0) \
30 BIT1(OP, ARG, RES, V2, R0, R1, R2, V0, V1) \
31 BIT1(OP, ARG, RES, R0, R1, R2, V0, V1, V2) \
32 BIT1(OP, ARG, RES, R1, R2, V0, V1, V2, R0) \
33 BIT1(OP, ARG, RES, R2, V0, V1, V2, R0, R1)
35 #define POPCNT(ARG, RES) \
36 BIT(popcnt, ARG, RES, v0, v1, v2, r0, r1, r2)
55 blti popcnt_loop %v1 __WORDSIZE
68 ldxi %r0 %v0 $(__WORDSIZE >> 3)
80 movi %v0 0x984a137ffec85219
110 POPCNT(0x8a13c851, 12)
111 POPCNT(0x12345678, 13)
112 POPCNT(0x02468ace, 12)
114 POPCNT(0x984a137ffec85219, 32)
115 POPCNT(0x123456789abcdef0, 32)
116 POPCNT(0x02468ace013579bd, 28)