Debian Codegraph @

gcc/testsuite/gcc.dg/fold-popcount-7.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-optimized" } */
3
4 int foo(unsigned int x)
5 {
6 #if __SIZEOF_INT__ == 4
7 unsigned int y = (x>>4) | (x<<28);
8 return __builtin_popcount(y);
9 #elif __SIZEOF_INT__ == 2
10 unsigned int y = (x>>4) | (x<<12);
11 return __builtin_popcount(y);
12 #else
13 return x;
14 #endif
15 }
16
17 int bar(unsigned long x)
18 {
19 #if __SIZEOF_LONG__ == 8
20 unsigned long y = (x>>4) | (x<<60);
21 return __builtin_popcountl (y);
22 #elif __SIZEOF_LONG__ == 4
23 unsigned long y = (x>>4) | (x<<28);
24 return __builtin_popcountl (y);
25 #else
26 return x;
27 #endif
28 }
29
30 int baz(unsigned long long x)
31 {
32 #if __SIZEOF_LONG_LONG__ == 8
33 unsigned long long y = (x>>4) | (x<<60);
34 return __builtin_popcountll (y);
35 #elif __SIZEOF_LONG_LONG__ == 4
36 unsigned long long y = (x>>4) | (x<<28);
37 return __builtin_popcountll (y);
38 #else
39 return x;
40 #endif
41 }
42
43 /* { dg-final { scan-tree-dump-not " r>> " "optimized" } } */