aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-popcount-5.c
blob: 943726f090229042c938d80e2cf131daf229dd47 (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
29
30
31
32
33
34
35
36
37
38
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */

int test_and4(unsigned int a)
{
  return __builtin_popcount(a&4);
}

int test_and4l(unsigned long b)
{
  return __builtin_popcountl(b&4);
}

int test_and4ll(unsigned long long c)
{
  return __builtin_popcountll(c&4);
}

int test_shift(unsigned int d)
{
  int bits = 8*sizeof(unsigned int)-1;
  return __builtin_popcount(d<<31);
}

int test_shiftl(unsigned long e)
{
  int bits = 8*sizeof(unsigned long)-1;
  return __builtin_popcountl(e<<bits);
}

int test_shiftll(unsigned long long f)
{
  int bits = 8*sizeof(unsigned long long)-1;
  return __builtin_popcountll(f<<bits);
}

/* { dg-final { scan-tree-dump-times "popcount" 0 "optimized" } } */