Wattributes-10.c: Add -fno-common option on hppa*-*-hpux*.
[official-gcc.git] / gcc / testsuite / c-c++-common / rotate-5.c
blob629ab2f7274ef44ba8be33444676cfee63368e77
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
4 extern
5 #ifdef __cplusplus
6 "C"
7 #endif
8 void abort (void);
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)
15 return (x << y) | (x >> ((-y) & 63));
18 __attribute__((noinline, noclone))
19 unsigned long long
20 f2 (unsigned long long x, unsigned int y)
22 return (x << y) + (x >> ((-y) & 63));
25 __attribute__((noinline, noclone))
26 unsigned long long
27 f3 (unsigned long long x, unsigned int y)
29 return (x << y) ^ (x >> ((-y) & 63));
32 #if __CHAR_BIT__ * __SIZEOF_INT128__ == 128
33 __attribute__((noinline, noclone))
34 unsigned __int128
35 f4 (unsigned __int128 x, unsigned int y)
37 return (x << y) | (x >> ((-y) & 127));
40 __attribute__((noinline, noclone))
41 unsigned __int128
42 f5 (unsigned __int128 x, unsigned int y)
44 return (x << y) + (x >> ((-y) & 127));
47 __attribute__((noinline, noclone))
48 unsigned __int128
49 f6 (unsigned __int128 x, unsigned int y)
51 return (x << y) ^ (x >> ((-y) & 127));
53 #endif
54 #endif
56 int
57 main ()
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;