aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-popcount-9.c
blob: a9ffa62a0735e75c3a48b45fd413c167457a2b17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */

#define popc __builtin_popcount

int foo1(unsigned int x, unsigned int y)
{
  return popc (x) + popc (y) - popc (x&y);
}

int foo2(unsigned int x, unsigned int y)
{
  return popc (y) + popc (x) - popc (x&y);
}

int foo3(unsigned int x, unsigned int y)
{
  return (popc (x) - popc (x&y)) + popc (y);
}

int foo4(unsigned int x, unsigned int y)
{
  return (popc (y) - popc (x&y)) + popc (x);
}

/* { dg-final { scan-tree-dump-not " & " "optimized" } } */
/* { dg-final { scan-tree-dump-times " \\| " 4 "optimized" } } */
/* { dg-final { scan-tree-dump-times "popcount " 4 "optimized" } } */