Debian Codegraph @

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

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-optimized" } */
3
4 #define popc __builtin_popcount
5
6 int foo1(unsigned int x, unsigned int y)
7 {
8 return popc (x) + popc (y) - popc (x&y);
9 }
10
11 int foo2(unsigned int x, unsigned int y)
12 {
13 return popc (y) + popc (x) - popc (x&y);
14 }
15
16 int foo3(unsigned int x, unsigned int y)
17 {
18 return (popc (x) - popc (x&y)) + popc (y);
19 }
20
21 int foo4(unsigned int x, unsigned int y)
22 {
23 return (popc (y) - popc (x&y)) + popc (x);
24 }
25
26 /* { dg-final { scan-tree-dump-not " & " "optimized" } } */
27 /* { dg-final { scan-tree-dump-times " \\| " 4 "optimized" } } */
28 /* { dg-final { scan-tree-dump-times "popcount " 4 "optimized" } } */