libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / popcount5l.c
blobb761667099f31c18975b0d021a9e212316d8a5bd
1 /* PR tree-optimization/94800 */
2 /* { dg-do compile { target int32plus } } */
3 /* { dg-require-effective-target popcountl } */
4 /* { dg-options "-O2 -fdump-tree-optimized" } */
6 #if __SIZEOF_LONG__ == 4
7 const unsigned long m1 = 0x55555555UL;
8 const unsigned long m2 = 0x33333333UL;
9 const unsigned long m4 = 0x0F0F0F0FUL;
10 const int shift = 24;
11 #else
12 const unsigned long m1 = 0x5555555555555555UL;
13 const unsigned long m2 = 0x3333333333333333UL;
14 const unsigned long m4 = 0x0f0f0f0f0f0f0f0fUL;
15 const int shift = 56;
16 #endif
19 int popcount64c(unsigned long x)
21 x -= (x >> 1) & m1;
22 x = (x & m2) + ((x >> 2) & m2);
23 x = (x + (x >> 4)) & m4;
24 x += (x << 8);
25 x += (x << 16);
26 #if __SIZEOF_LONG__ != 4
27 x += (x << 32);
28 #endif
29 return x >> shift;
32 /* { dg-final { scan-tree-dump-times "\.POPCOUNT" 1 "optimized" } } */