aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-parity-6.c
blob: a407597854e2f4a48396e2cc475f99c877944b34 (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
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */

int foo(unsigned int x)
{
#if __SIZEOF_INT__ == 4
  return __builtin_parity (__builtin_bswap32(x));
#elif __SIZEOF_INT__ == 2
  return __builtin_parity (__builtin_bswap16(x));
#else
  return x;
#endif
}

int bar(unsigned long x)
{
#if __SIZEOF_LONG__ == 8
  return __builtin_parityl (__builtin_bswap64(x));
#elif __SIZEOF_LONG__ == 4
  return __builtin_parityl (__builtin_bswap32(x));
#else
  return x;
#endif
}

int baz(unsigned long long x)
{
#if __SIZEOF_LONG_LONG__ == 8
  return __builtin_parityll (__builtin_bswap64(x));
#elif __SIZEOF_LONG_LONG__ == 4
  return __builtin_parityll (__builtin_bswap32(x));
#else
  return x;
#endif
}

/* { dg-final { scan-tree-dump-not "bswap" "optimized" } } */