145
|
1 /* { dg-do compile } */
|
|
2 /* { dg-require-effective-target popcount } */
|
|
3 /* { dg-require-effective-target int32plus } */
|
|
4 /* { dg-options "-O2 -fdump-tree-optimized" } */
|
|
5
|
|
6 const unsigned m1 = 0x55555555UL;
|
|
7 const unsigned m2 = 0x33333333UL;
|
|
8 const unsigned m4 = 0x0F0F0F0FUL;
|
|
9 const unsigned h01 = 0x01010101UL;
|
|
10 const int shift = 24;
|
|
11
|
|
12 int popcount64c(unsigned x)
|
|
13 {
|
|
14 x -= (x >> 1) & m1;
|
|
15 x = (x & m2) + ((x >> 2) & m2);
|
|
16 x = (x + (x >> 4)) & m4;
|
|
17 return (x * h01) >> shift;
|
|
18 }
|
|
19
|
|
20 /* { dg-final { scan-tree-dump-times "\.POPCOUNT" 1 "optimized" } } */
|
|
21
|
|
22
|