aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/rotate-5.c
blob: 35b14b86c3afd0c6ef19d328c972fa5b1c9db449 (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
40
41
42
43
/* { dg-do run } */
/* { dg-options "-O2" } */

extern
#ifdef __cplusplus
"C"
#endif
void abort (void);

#if __CHAR_BIT__ * __SIZEOF_LONG_LONG__ == 64
__attribute__((noinline, noclone))
unsigned long long
f1 (unsigned long long x, unsigned int y)
{
  return (x << y) | (x >> ((-y) & 63));
}

#if __CHAR_BIT__ * __SIZEOF_INT128__ == 128
__attribute__((noinline, noclone))
unsigned __int128
f2 (unsigned __int128 x, unsigned int y)
{
  return (x << y) | (x >> ((-y) & 128));
}
#endif
#endif

int
main ()
{
#if __CHAR_BIT__ * __SIZEOF_LONG_LONG__ == 64
  if (f1 (0x123456789abcdef0ULL, 0) != 0x123456789abcdef0ULL)
    abort ();
#if __CHAR_BIT__ * __SIZEOF_INT128__ == 128
  if (f2 ((((unsigned __int128) 0x123456789abcdef0ULL) << 64)
	  | 0x0fedcba987654321ULL, 0)
      != ((((unsigned __int128) 0x123456789abcdef0ULL) << 64)
          | 0x0fedcba987654321ULL))
    abort ();
#endif
#endif
  return 0;
}