Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/c-c++-common/rotate-5.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* { dg-do run } */ | |
2 /* { dg-options "-O2" } */ | |
3 | |
4 extern | |
5 #ifdef __cplusplus | |
6 "C" | |
7 #endif | |
8 void abort (void); | |
9 | |
10 #if __CHAR_BIT__ * __SIZEOF_LONG_LONG__ == 64 | |
11 __attribute__((noinline, noclone)) | |
12 unsigned long long | |
13 f1 (unsigned long long x, unsigned int y) | |
14 { | |
15 return (x << y) | (x >> ((-y) & 63)); | |
16 } | |
17 | |
18 __attribute__((noinline, noclone)) | |
19 unsigned long long | |
20 f2 (unsigned long long x, unsigned int y) | |
21 { | |
22 return (x << y) + (x >> ((-y) & 63)); | |
23 } | |
24 | |
25 __attribute__((noinline, noclone)) | |
26 unsigned long long | |
27 f3 (unsigned long long x, unsigned int y) | |
28 { | |
29 return (x << y) ^ (x >> ((-y) & 63)); | |
30 } | |
31 | |
32 #if __CHAR_BIT__ * __SIZEOF_INT128__ == 128 | |
33 __attribute__((noinline, noclone)) | |
34 unsigned __int128 | |
35 f4 (unsigned __int128 x, unsigned int y) | |
36 { | |
37 return (x << y) | (x >> ((-y) & 127)); | |
38 } | |
39 | |
40 __attribute__((noinline, noclone)) | |
41 unsigned __int128 | |
42 f5 (unsigned __int128 x, unsigned int y) | |
43 { | |
44 return (x << y) + (x >> ((-y) & 127)); | |
45 } | |
46 | |
47 __attribute__((noinline, noclone)) | |
48 unsigned __int128 | |
49 f6 (unsigned __int128 x, unsigned int y) | |
50 { | |
51 return (x << y) ^ (x >> ((-y) & 127)); | |
52 } | |
53 #endif | |
54 #endif | |
55 | |
56 int | |
57 main () | |
58 { | |
59 #if __CHAR_BIT__ * __SIZEOF_LONG_LONG__ == 64 | |
60 if (f1 (0x123456789abcdef0ULL, 0) != 0x123456789abcdef0ULL) | |
61 abort (); | |
62 if (f2 (0x123456789abcdef0ULL, 0) != 0x2468acf13579bde0ULL) | |
63 abort (); | |
64 if (f3 (0x123456789abcdef0ULL, 0) != 0) | |
65 abort (); | |
66 if (f1 (0x123456789abcdef0ULL, 1) != 0x2468acf13579bde0ULL) | |
67 abort (); | |
68 if (f2 (0x123456789abcdef0ULL, 1) != 0x2468acf13579bde0ULL) | |
69 abort (); | |
70 if (f3 (0x123456789abcdef0ULL, 1) != 0x2468acf13579bde0ULL) | |
71 abort (); | |
72 #if __CHAR_BIT__ * __SIZEOF_INT128__ == 128 | |
73 if (f4 ((((unsigned __int128) 0x123456789abcdef0ULL) << 64) | |
74 | 0x0fedcba987654321ULL, 0) | |
75 != ((((unsigned __int128) 0x123456789abcdef0ULL) << 64) | |
76 | 0x0fedcba987654321ULL)) | |
77 abort (); | |
78 if (f5 ((((unsigned __int128) 0x123456789abcdef0ULL) << 64) | |
79 | 0x0fedcba987654321ULL, 0) | |
80 != ((((unsigned __int128) 0x2468acf13579bde0ULL) << 64) | |
81 | 0x1fdb97530eca8642ULL)) | |
82 abort (); | |
83 if (f6 ((((unsigned __int128) 0x123456789abcdef0ULL) << 64) | |
84 | 0x0fedcba987654321ULL, 0) != 0) | |
85 abort (); | |
86 if (f4 ((((unsigned __int128) 0x123456789abcdef0ULL) << 64) | |
87 | 0x0fedcba987654321ULL, 1) | |
88 != ((((unsigned __int128) 0x2468acf13579bde0ULL) << 64) | |
89 | 0x1fdb97530eca8642ULL)) | |
90 abort (); | |
91 if (f5 ((((unsigned __int128) 0x123456789abcdef0ULL) << 64) | |
92 | 0x0fedcba987654321ULL, 1) | |
93 != ((((unsigned __int128) 0x2468acf13579bde0ULL) << 64) | |
94 | 0x1fdb97530eca8642ULL)) | |
95 abort (); | |
96 if (f6 ((((unsigned __int128) 0x123456789abcdef0ULL) << 64) | |
97 | 0x0fedcba987654321ULL, 1) | |
98 != ((((unsigned __int128) 0x2468acf13579bde0ULL) << 64) | |
99 | 0x1fdb97530eca8642ULL)) | |
100 abort (); | |
101 #endif | |
102 #endif | |
103 return 0; | |
104 } |