| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-std=c11" } */ |
| 3 |
|
| 4 |
unsigned long long |
| 5 |
rotate_left (unsigned char a, unsigned short b, unsigned int c, |
| 6 |
unsigned long d, unsigned long long e, int n) |
| 7 |
{ |
| 8 |
return (__builtin_stdc_rotate_left (a, n) |
| 9 |
+ __builtin_stdc_rotate_left (b, n) |
| 10 |
+ __builtin_stdc_rotate_left (c, n) |
| 11 |
+ __builtin_stdc_rotate_left (d, n) |
| 12 |
+ __builtin_stdc_rotate_left (e, n)); |
| 13 |
} |
| 14 |
|
| 15 |
unsigned long long |
| 16 |
rotate_right (unsigned char a, unsigned short b, unsigned int c, |
| 17 |
unsigned long d, unsigned long long e, int n) |
| 18 |
{ |
| 19 |
return (__builtin_stdc_rotate_right (a, n) |
| 20 |
+ __builtin_stdc_rotate_right (b, n) |
| 21 |
+ __builtin_stdc_rotate_right (c, n) |
| 22 |
+ __builtin_stdc_rotate_right (d, n) |
| 23 |
+ __builtin_stdc_rotate_right (e, n)); |
| 24 |
} |
| 25 |
|
| 26 |
#define expr_has_type(e, t) _Generic (e, default : 0, t : 1) |
| 27 |
|
| 28 |
int |
| 29 |
main () |
| 30 |
{ |
| 31 |
if (__builtin_stdc_rotate_left ((unsigned char) 0, 0) != 0 |
| 32 |
|| __builtin_stdc_rotate_left ((unsigned char) 0xdcU, (char) 0) != 0xdcU |
| 33 |
|| __builtin_stdc_rotate_left ((unsigned char) 0xdcU, __CHAR_BIT__) != 0xdcU |
| 34 |
|| __builtin_stdc_rotate_left ((unsigned char) 0xdcU, 2 * __CHAR_BIT__) != 0xdcU |
| 35 |
|| !expr_has_type (__builtin_stdc_rotate_left ((unsigned char) 0, 0), unsigned char) |
| 36 |
|| __builtin_stdc_rotate_left ((unsigned char) 1, (_Bool) 1) != 2 |
| 37 |
|| !expr_has_type (__builtin_stdc_rotate_left ((unsigned char) 1, (unsigned char) 1), unsigned char) |
| 38 |
|| __builtin_stdc_rotate_left ((unsigned char) ~1U, 3) != (unsigned char) ~8U |
| 39 |
|| __builtin_stdc_rotate_left ((unsigned char) (2U + __SCHAR_MAX__), 1) != 3 |
| 40 |
|| __builtin_stdc_rotate_left ((unsigned char) (2U + __SCHAR_MAX__), __CHAR_BIT__ + 1) != 3 |
| 41 |
|| __builtin_stdc_rotate_left ((unsigned short) 0, 0) != 0 |
| 42 |
|| __builtin_stdc_rotate_left ((unsigned short) 0xdcabU, 0) != 0xdcabU |
| 43 |
|| !expr_has_type (__builtin_stdc_rotate_left ((unsigned short) 0, (signed char) 0), unsigned short) |
| 44 |
|| __builtin_stdc_rotate_left ((unsigned short) 1, 13) != (1U << 13) |
| 45 |
|| !expr_has_type (__builtin_stdc_rotate_left ((unsigned short) 1, 13), unsigned short) |
| 46 |
|| __builtin_stdc_rotate_left ((unsigned short) ~1U, 7) != (unsigned short) ~0x80U |
| 47 |
|| __builtin_stdc_rotate_left ((unsigned short) (2U + __SHRT_MAX__), 1) != 3 |
| 48 |
|| __builtin_stdc_rotate_left (0U, 0) != 0 |
| 49 |
|| __builtin_stdc_rotate_left (0xcdbaU, (short int) 0) != 0xcdbaU |
| 50 |
|| !expr_has_type (__builtin_stdc_rotate_left (0U, 0), unsigned int) |
| 51 |
|| __builtin_stdc_rotate_left (1U, (char) 15) != (1U << 15) |
| 52 |
|| !expr_has_type (__builtin_stdc_rotate_left (1U, 15), unsigned int) |
| 53 |
|| __builtin_stdc_rotate_left (~1U, 9) != ~0x200U |
| 54 |
|| __builtin_stdc_rotate_left (2U + __INT_MAX__, 1) != 3 |
| 55 |
|| __builtin_stdc_rotate_left (0UL, 0) != 0 |
| 56 |
|| __builtin_stdc_rotate_left (0xdc8971baUL, 0) != 0xdc8971baUL |
| 57 |
|| !expr_has_type (__builtin_stdc_rotate_left (0UL, 0LL), unsigned long) |
| 58 |
|| __builtin_stdc_rotate_left (1UL, 30) != (1UL << 30) |
| 59 |
|| !expr_has_type (__builtin_stdc_rotate_left (1UL, 30), unsigned long) |
| 60 |
|| __builtin_stdc_rotate_left (~1UL, 22) != ~0x400000UL |
| 61 |
|| __builtin_stdc_rotate_left (2UL + __LONG_MAX__, 1) != 3 |
| 62 |
|| __builtin_stdc_rotate_left (2UL + __LONG_MAX__, (int) (sizeof (unsigned long) * __CHAR_BIT__) + 1) != 3 |
| 63 |
|| __builtin_stdc_rotate_left (0ULL, (_Bool) 0) != 0 |
| 64 |
|| __builtin_stdc_rotate_left (0xdc897143985734baULL, 0) != 0xdc897143985734baULL |
| 65 |
|| __builtin_stdc_rotate_left (0xdc897143985734baULL, 4 * (int) (sizeof (unsigned long long) * __CHAR_BIT__)) != 0xdc897143985734baULL |
| 66 |
|| !expr_has_type (__builtin_stdc_rotate_left (0ULL, 0), unsigned long long) |
| 67 |
|| __builtin_stdc_rotate_left (1ULL, 62) != (1ULL << 62) |
| 68 |
|| !expr_has_type (__builtin_stdc_rotate_left (1ULL, 62ULL), unsigned long long) |
| 69 |
|| __builtin_stdc_rotate_left (~1ULL, 53) != ~0x20000000000000ULL |
| 70 |
|| __builtin_stdc_rotate_left (2ULL + __LONG_LONG_MAX__, 1) != 3) |
| 71 |
__builtin_abort (); |
| 72 |
if (__builtin_stdc_rotate_right ((unsigned char) 0, 0) != 0 |
| 73 |
|| __builtin_stdc_rotate_right ((unsigned char) 0xdcU, 0) != 0xdcU |
| 74 |
|| !expr_has_type (__builtin_stdc_rotate_right ((unsigned char) 0, 0), unsigned char) |
| 75 |
|| __builtin_stdc_rotate_right ((unsigned char) 1, 1) != (1U + __SCHAR_MAX__) |
| 76 |
|| !expr_has_type (__builtin_stdc_rotate_right ((unsigned char) 1, 1), unsigned char) |
| 77 |
|| __builtin_stdc_rotate_right ((unsigned char) ~1U, (char) 3) != (unsigned char) ~((1U + __SCHAR_MAX__) >> 2) |
| 78 |
|| __builtin_stdc_rotate_right ((unsigned char) 3, 1) != (2U + __SCHAR_MAX__) |
| 79 |
|| __builtin_stdc_rotate_right ((unsigned short) 0, 0) != 0 |
| 80 |
|| __builtin_stdc_rotate_right ((unsigned short) 0xdcabU, 0) != 0xdcabU |
| 81 |
|| __builtin_stdc_rotate_right ((unsigned short) 0xdcabU, sizeof (unsigned short) * __CHAR_BIT__) != 0xdcabU |
| 82 |
|| !expr_has_type (__builtin_stdc_rotate_right ((unsigned short) 0, 0), unsigned short) |
| 83 |
|| __builtin_stdc_rotate_right ((unsigned short) (1U << 13), 12) != 2 |
| 84 |
|| !expr_has_type (__builtin_stdc_rotate_right ((unsigned short) (1U << 13), 2), unsigned short) |
| 85 |
|| __builtin_stdc_rotate_right ((unsigned short) ~1U, 7) != (unsigned short) ~((1U + __SHRT_MAX__) >> 6) |
| 86 |
|| __builtin_stdc_rotate_right ((unsigned short) 3, 1) != (2U + __SHRT_MAX__) |
| 87 |
|| __builtin_stdc_rotate_right (0U, 0) != 0 |
| 88 |
|| __builtin_stdc_rotate_right (0xcdbaU, 0) != 0xcdbaU |
| 89 |
|| !expr_has_type (__builtin_stdc_rotate_right (0U, 0), unsigned int) |
| 90 |
|| __builtin_stdc_rotate_right (1U << 15, 13) != 4U |
| 91 |
|| !expr_has_type (__builtin_stdc_rotate_right (1U << 15, 13), unsigned int) |
| 92 |
|| __builtin_stdc_rotate_right (~1U, 9) != ~((1U + __INT_MAX__) >> 8) |
| 93 |
|| __builtin_stdc_rotate_right (3U, (_Bool) 1) != (2U + __INT_MAX__) |
| 94 |
|| __builtin_stdc_rotate_right (3U, (int) (sizeof (unsigned) * __CHAR_BIT__) + 1) != (2U + __INT_MAX__) |
| 95 |
|| __builtin_stdc_rotate_right (0UL, (_Bool) 0) != 0 |
| 96 |
|| __builtin_stdc_rotate_right (0xdc8971baUL, 0) != 0xdc8971baUL |
| 97 |
|| !expr_has_type (__builtin_stdc_rotate_right (0UL, 0), unsigned long) |
| 98 |
|| __builtin_stdc_rotate_right (1UL << 30, 27) != 8UL |
| 99 |
|| !expr_has_type (__builtin_stdc_rotate_right (1UL << 30, 27), unsigned long) |
| 100 |
|| __builtin_stdc_rotate_right (~1UL, 22) != ~((1UL + __LONG_MAX__) >> 21) |
| 101 |
|| __builtin_stdc_rotate_right (3UL, 1) != (2UL + __LONG_MAX__) |
| 102 |
|| __builtin_stdc_rotate_right (0ULL, 0) != 0 |
| 103 |
|| __builtin_stdc_rotate_right (0xdc897143985734baULL, 0) != 0xdc897143985734baULL |
| 104 |
|| !expr_has_type (__builtin_stdc_rotate_right (0ULL, 0), unsigned long long) |
| 105 |
|| __builtin_stdc_rotate_right (1ULL << 62, 60) != 4ULL |
| 106 |
|| !expr_has_type (__builtin_stdc_rotate_right (1ULL << 62, 60), unsigned long long) |
| 107 |
|| __builtin_stdc_rotate_right (~1ULL, 53) != ~((1ULL + __LONG_LONG_MAX__) >> 52) |
| 108 |
|| __builtin_stdc_rotate_right (3ULL, 1) != (2ULL + __LONG_LONG_MAX__)) |
| 109 |
__builtin_abort (); |
| 110 |
#ifdef __SIZEOF_INT128__ |
| 111 |
if (__builtin_stdc_rotate_left ((unsigned __int128) 0U, 0) != 0 |
| 112 |
|| __builtin_stdc_rotate_left (((unsigned __int128) 0x43256567547ULL) << 64 | 0xdc897143985734baULL, 0) != (((unsigned __int128) 0x43256567547ULL) << 64 | 0xdc897143985734baULL) |
| 113 |
|| !expr_has_type (__builtin_stdc_rotate_left ((unsigned __int128) 0U, 0), unsigned __int128) |
| 114 |
|| __builtin_stdc_rotate_left ((unsigned __int128) 1U, 115) != ((unsigned __int128) 1U << 115) |
| 115 |
|| !expr_has_type (__builtin_stdc_rotate_left ((unsigned __int128) 1U, 115), unsigned __int128) |
| 116 |
|| __builtin_stdc_rotate_left (~(unsigned __int128) 1ULL, 53) != ~(unsigned __int128) 0x20000000000000ULL |
| 117 |
|| __builtin_stdc_rotate_left (1ULL + ((unsigned __int128) 1U << 127), 1) != 3) |
| 118 |
__builtin_abort (); |
| 119 |
if (__builtin_stdc_rotate_right (0ULL, 0) != 0 |
| 120 |
|| __builtin_stdc_rotate_right (((unsigned __int128) 0x43256567547ULL) << 64 | 0xdc897143985734baULL, 0) != (((unsigned __int128) 0x43256567547ULL) << 64 | 0xdc897143985734baULL) |
| 121 |
|| !expr_has_type (__builtin_stdc_rotate_right ((unsigned __int128) 0U, 0), unsigned __int128) |
| 122 |
|| __builtin_stdc_rotate_right ((unsigned __int128) 1ULL << 115, 110) != 32U |
| 123 |
|| !expr_has_type (__builtin_stdc_rotate_right ((unsigned __int128) 1ULL << 115, 110), unsigned __int128) |
| 124 |
|| __builtin_stdc_rotate_right (~(unsigned __int128) 1ULL, 53) != ~((unsigned __int128) 1 << 75) |
| 125 |
|| __builtin_stdc_rotate_right ((unsigned __int128) 3ULL, 1) != 1U + ((unsigned __int128) 1U << 127)) |
| 126 |
__builtin_abort (); |
| 127 |
#endif |
| 128 |
#if __has_builtin (__builtin_stdc_rotate_left) != 1 |
| 129 |
#error __builtin_stdc_rotate_left not implemented |
| 130 |
#endif |
| 131 |
#if __has_builtin (__builtin_stdc_rotate_right) != 1 |
| 132 |
#error __builtin_stdc_rotate_right not implemented |
| 133 |
#endif |
| 134 |
unsigned char a = 1; |
| 135 |
unsigned short b = 1; |
| 136 |
unsigned int c = 1; |
| 137 |
unsigned long d = 1; |
| 138 |
unsigned long long e = 1; |
| 139 |
int f = 1; |
| 140 |
if (__builtin_stdc_rotate_left (a++, f++) != 2 || a != 2 || f != 2) |
| 141 |
__builtin_abort (); |
| 142 |
if (__builtin_stdc_rotate_left (b++, f++) != 4 || b != 2 || f != 3) |
| 143 |
__builtin_abort (); |
| 144 |
if (__builtin_stdc_rotate_left (c++, f++) != 8 || c != 2 || f != 4) |
| 145 |
__builtin_abort (); |
| 146 |
if (__builtin_stdc_rotate_left (d++, f++) != 16 || d != 2 || f != 5) |
| 147 |
__builtin_abort (); |
| 148 |
if (__builtin_stdc_rotate_left (e++, f++) != 32 || e != 2 || f != 6) |
| 149 |
__builtin_abort (); |
| 150 |
f = 1; |
| 151 |
if (__builtin_stdc_rotate_right (a++, f++) != 1 || a != 3 || f != 2) |
| 152 |
__builtin_abort (); |
| 153 |
f = 1; |
| 154 |
if (__builtin_stdc_rotate_right (b++, f++) != 1 || b != 3 || f != 2) |
| 155 |
__builtin_abort (); |
| 156 |
f = 1; |
| 157 |
if (__builtin_stdc_rotate_right (c++, f++) != 1 || c != 3 || f != 2) |
| 158 |
__builtin_abort (); |
| 159 |
f = 1; |
| 160 |
if (__builtin_stdc_rotate_right (d++, f++) != 1 || d != 3 || f != 2) |
| 161 |
__builtin_abort (); |
| 162 |
f = 1; |
| 163 |
if (__builtin_stdc_rotate_right (e++, f++) != 1 || e != 3 || f != 2) |
| 164 |
__builtin_abort (); |
| 165 |
#ifdef __SIZEOF_INT128__ |
| 166 |
unsigned __int128 g = 1; |
| 167 |
if (__builtin_stdc_rotate_left (g++, f++) != 4 || g != 2 || f != 3) |
| 168 |
__builtin_abort (); |
| 169 |
f = 1; |
| 170 |
if (__builtin_stdc_rotate_right (g++, f++) != 1 || g != 3 || f != 2) |
| 171 |
__builtin_abort (); |
| 172 |
#endif |
| 173 |
#if __BITINT_MAXWIDTH__ >= 64 |
| 174 |
if (__builtin_stdc_rotate_left (0uwb, 0) != 0 |
| 175 |
|| __builtin_stdc_rotate_left (1uwb, 0) != 1uwb |
| 176 |
|| !expr_has_type (__builtin_stdc_rotate_left (0uwb, 0), unsigned _BitInt(1))) |
| 177 |
__builtin_abort (); |
| 178 |
if (__builtin_stdc_rotate_left ((unsigned _BitInt(2)) 0, 0) != 0 |
| 179 |
|| __builtin_stdc_rotate_left ((unsigned _BitInt(2)) 1, (_BitInt(27)) 1) != 2uwb |
| 180 |
|| !expr_has_type (__builtin_stdc_rotate_left ((unsigned _BitInt(2)) 0, 0), unsigned _BitInt(2)) |
| 181 |
|| __builtin_stdc_rotate_left ((unsigned _BitInt(2)) 1, 1) != 2 |
| 182 |
|| !expr_has_type (__builtin_stdc_rotate_left ((unsigned _BitInt(2)) 1, (unsigned _BitInt(2)) 1), unsigned _BitInt(2)) |
| 183 |
|| __builtin_stdc_rotate_left ((unsigned _BitInt(2)) 2, 1) != 1) |
| 184 |
__builtin_abort (); |
| 185 |
if (__builtin_stdc_rotate_right (0uwb, 0) != 0 |
| 186 |
|| __builtin_stdc_rotate_right (1uwb, 0) != 1uwb |
| 187 |
|| !expr_has_type (__builtin_stdc_rotate_right (0uwb, 0), unsigned _BitInt(1))) |
| 188 |
__builtin_abort (); |
| 189 |
if (__builtin_stdc_rotate_right ((unsigned _BitInt(2)) 0, (_BitInt(3)) 0) != 0 |
| 190 |
|| __builtin_stdc_rotate_right ((unsigned _BitInt(2)) 1, 1) != 2uwb |
| 191 |
|| !expr_has_type (__builtin_stdc_rotate_right ((unsigned _BitInt(2)) 0, 0), unsigned _BitInt(2)) |
| 192 |
|| __builtin_stdc_rotate_right ((unsigned _BitInt(2)) 1, 1) != 2 |
| 193 |
|| !expr_has_type (__builtin_stdc_rotate_right ((unsigned _BitInt(2)) 1, 1), unsigned _BitInt(2)) |
| 194 |
|| __builtin_stdc_rotate_right ((unsigned _BitInt(2)) 2, 1) != 1) |
| 195 |
__builtin_abort (); |
| 196 |
if (__builtin_stdc_rotate_left ((unsigned _BitInt(59)) 0U, 0) != 0 |
| 197 |
|| __builtin_stdc_rotate_left ((unsigned _BitInt(59)) 0x43256567547ULL, 0) != ((unsigned _BitInt(59)) 0x43256567547ULL) |
| 198 |
|| !expr_has_type (__builtin_stdc_rotate_left ((unsigned _BitInt(59)) 0U, 0), unsigned _BitInt(59)) |
| 199 |
|| __builtin_stdc_rotate_left ((unsigned _BitInt(59)) 1U, 57) != ((unsigned _BitInt(59)) 1U << 57) |
| 200 |
|| !expr_has_type (__builtin_stdc_rotate_left ((unsigned _BitInt(59)) 1U, 57), unsigned _BitInt(59)) |
| 201 |
|| __builtin_stdc_rotate_left (~(unsigned _BitInt(59)) 1ULL, 53) != ~(unsigned _BitInt(59)) 0x20000000000000ULL |
| 202 |
|| __builtin_stdc_rotate_left (1uwb + ((unsigned _BitInt(59)) 1U << 58), 1) != 3) |
| 203 |
__builtin_abort (); |
| 204 |
if (__builtin_stdc_rotate_right (0ULL, 0) != 0 |
| 205 |
|| __builtin_stdc_rotate_right ((unsigned _BitInt(59)) 0x43256567547ULL, 0) != ((unsigned _BitInt(59)) 0x43256567547ULL) |
| 206 |
|| !expr_has_type (__builtin_stdc_rotate_right ((unsigned _BitInt(59)) 0U, 0), unsigned _BitInt(59)) |
| 207 |
|| __builtin_stdc_rotate_right ((unsigned _BitInt(59)) 1ULL << 57, 55) != 4U |
| 208 |
|| !expr_has_type (__builtin_stdc_rotate_right ((unsigned _BitInt(59)) 1U << 57, 55), unsigned _BitInt(59)) |
| 209 |
|| __builtin_stdc_rotate_right (~(unsigned _BitInt(59)) 1ULL, 53) != ~((unsigned _BitInt(59)) 1 << 6) |
| 210 |
|| __builtin_stdc_rotate_right ((unsigned _BitInt(59)) 3ULL, 1) != 1uwb + ((unsigned _BitInt(59)) 1U << 58)) |
| 211 |
__builtin_abort (); |
| 212 |
#endif |
| 213 |
#if __BITINT_MAXWIDTH__ >= 512 |
| 214 |
if (__builtin_stdc_rotate_left ((unsigned _BitInt(510)) 0U, (_BitInt(503)) 0) != 0 |
| 215 |
|| __builtin_stdc_rotate_left (((unsigned _BitInt(510)) 0x43256567547ULL) << 64 | 0xdc897143985734baULL, 0) != (((unsigned _BitInt(510)) 0x43256567547ULL) << 64 | 0xdc897143985734baULL) |
| 216 |
|| __builtin_stdc_rotate_left (((unsigned _BitInt(510)) 0x43256567547ULL) << 64 | 0xdc897143985734baULL, 510) != (((unsigned _BitInt(510)) 0x43256567547ULL) << 64 | 0xdc897143985734baULL) |
| 217 |
|| !expr_has_type (__builtin_stdc_rotate_left ((unsigned _BitInt(510)) 0U, 0), unsigned _BitInt(510)) |
| 218 |
|| __builtin_stdc_rotate_left ((unsigned _BitInt(510)) 1U, 508) != ((unsigned _BitInt(510)) 1U << 508) |
| 219 |
|| !expr_has_type (__builtin_stdc_rotate_left ((unsigned _BitInt(510)) 1U, (unsigned _BitInt(505)) 508), unsigned _BitInt(510)) |
| 220 |
|| __builtin_stdc_rotate_left (~(unsigned _BitInt(510)) 1ULL, 53) != ~(unsigned _BitInt(510)) 0x20000000000000ULL |
| 221 |
|| __builtin_stdc_rotate_left (1uwb + ((unsigned _BitInt(510)) 1U << 509), 1) != 3 |
| 222 |
|| __builtin_stdc_rotate_left (1uwb + ((unsigned _BitInt(510)) 1U << 509), 511U) != 3) |
| 223 |
__builtin_abort (); |
| 224 |
if (__builtin_stdc_rotate_right (0ULL, 0) != 0 |
| 225 |
|| __builtin_stdc_rotate_right (((unsigned _BitInt(510)) 0x43256567547ULL) << 64 | 0xdc897143985734baULL, 0) != (((unsigned _BitInt(510)) 0x43256567547ULL) << 64 | 0xdc897143985734baULL) |
| 226 |
|| __builtin_stdc_rotate_right (((unsigned _BitInt(510)) 0x43256567547ULL) << 64 | 0xdc897143985734baULL, 510U * 2) != (((unsigned _BitInt(510)) 0x43256567547ULL) << 64 | 0xdc897143985734baULL) |
| 227 |
|| !expr_has_type (__builtin_stdc_rotate_right ((unsigned _BitInt(510)) 0U, 0), unsigned _BitInt(510)) |
| 228 |
|| __builtin_stdc_rotate_right ((unsigned _BitInt(510)) 1ULL << 508, 503) != 32U |
| 229 |
|| !expr_has_type (__builtin_stdc_rotate_right ((unsigned _BitInt(510)) 1ULL << 508, 503), unsigned _BitInt(510)) |
| 230 |
|| __builtin_stdc_rotate_right (~(unsigned _BitInt(510)) 1ULL, 499) != ~((unsigned _BitInt(510)) 1 << 11) |
| 231 |
|| __builtin_stdc_rotate_right ((unsigned _BitInt(510)) 3ULL, 1) != 1uwb + ((unsigned _BitInt(510)) 1U << 509) |
| 232 |
|| __builtin_stdc_rotate_right ((unsigned _BitInt(510)) 3ULL, 511) != 1uwb + ((unsigned _BitInt(510)) 1U << 509)) |
| 233 |
__builtin_abort (); |
| 234 |
#endif |
| 235 |
} |