aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-parity-5.c
blob: e30cd2f68e43a37903ae050e5d7a9e25090e900f (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
39
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
/* { dg-require-effective-target int32plus } */

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

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

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

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

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

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

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