struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-ashldi-1.c
blobb19d48b4cc959a9dc06c32f56fdc2b7e80d3e572
1 /*
2 ashldi-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #include <limits.h>
9 #ifndef __SDCC_pdk14 // Lack of memory
10 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
11 extern void abort(void);
12 extern void exit(int);
14 #if LLONG_MAX == 9223372036854775807LL
15 #define BITS 64
17 static unsigned long long const data[64] = {
18 0x123456789abcdefULL,
19 0x2468acf13579bdeULL,
20 0x48d159e26af37bcULL,
21 0x91a2b3c4d5e6f78ULL,
22 0x123456789abcdef0ULL,
23 0x2468acf13579bde0ULL,
24 0x48d159e26af37bc0ULL,
25 0x91a2b3c4d5e6f780ULL,
26 0x23456789abcdef00ULL,
27 0x468acf13579bde00ULL,
28 0x8d159e26af37bc00ULL,
29 0x1a2b3c4d5e6f7800ULL,
30 0x3456789abcdef000ULL,
31 0x68acf13579bde000ULL,
32 0xd159e26af37bc000ULL,
33 0xa2b3c4d5e6f78000ULL,
34 0x456789abcdef0000ULL,
35 0x8acf13579bde0000ULL,
36 0x159e26af37bc0000ULL,
37 0x2b3c4d5e6f780000ULL,
38 0x56789abcdef00000ULL,
39 0xacf13579bde00000ULL,
40 0x59e26af37bc00000ULL,
41 0xb3c4d5e6f7800000ULL,
42 0x6789abcdef000000ULL,
43 0xcf13579bde000000ULL,
44 0x9e26af37bc000000ULL,
45 0x3c4d5e6f78000000ULL,
46 0x789abcdef0000000ULL,
47 0xf13579bde0000000ULL,
48 0xe26af37bc0000000ULL,
49 0xc4d5e6f780000000ULL,
50 0x89abcdef00000000ULL,
51 0x13579bde00000000ULL,
52 0x26af37bc00000000ULL,
53 0x4d5e6f7800000000ULL,
54 0x9abcdef000000000ULL,
55 0x3579bde000000000ULL,
56 0x6af37bc000000000ULL,
57 0xd5e6f78000000000ULL,
58 0xabcdef0000000000ULL,
59 0x579bde0000000000ULL,
60 0xaf37bc0000000000ULL,
61 0x5e6f780000000000ULL,
62 0xbcdef00000000000ULL,
63 0x79bde00000000000ULL,
64 0xf37bc00000000000ULL,
65 0xe6f7800000000000ULL,
66 0xcdef000000000000ULL,
67 0x9bde000000000000ULL,
68 0x37bc000000000000ULL,
69 0x6f78000000000000ULL,
70 0xdef0000000000000ULL,
71 0xbde0000000000000ULL,
72 0x7bc0000000000000ULL,
73 0xf780000000000000ULL,
74 0xef00000000000000ULL,
75 0xde00000000000000ULL,
76 0xbc00000000000000ULL,
77 0x7800000000000000ULL,
78 0xf000000000000000ULL,
79 0xe000000000000000ULL,
80 0xc000000000000000ULL,
81 0x8000000000000000ULL
84 #elif LLONG_MAX == 2147483647LL
85 #define BITS 32
87 static unsigned long long const data[32] = {
88 0x1234567fULL,
89 0x2468acfeULL,
90 0x48d159fcULL,
91 0x91a2b3f8ULL,
92 0x234567f0ULL,
93 0x468acfe0ULL,
94 0x8d159fc0ULL,
95 0x1a2b3f80ULL,
96 0x34567f00ULL,
97 0x68acfe00ULL,
98 0xd159fc00ULL,
99 0xa2b3f800ULL,
100 0x4567f000ULL,
101 0x8acfe000ULL,
102 0x159fc000ULL,
103 0x2b3f8000ULL,
104 0x567f0000ULL,
105 0xacfe0000ULL,
106 0x59fc0000ULL,
107 0xb3f80000ULL,
108 0x67f00000ULL,
109 0xcfe00000ULL,
110 0x9fc00000ULL,
111 0x3f800000ULL,
112 0x7f000000ULL,
113 0xfe000000ULL,
114 0xfc000000ULL,
115 0xf8000000ULL,
116 0xf0000000ULL,
117 0xe0000000ULL,
118 0xc0000000ULL,
119 0x80000000ULL
122 #else
123 #error "Update the test case."
124 #endif
126 static unsigned long long
127 variable_shift(unsigned long long x, int i)
129 return x << i;
132 static unsigned long long
133 constant_shift(unsigned long long x, int i)
135 switch (i)
137 case 0: x = x << 0; break;
138 case 1: x = x << 1; break;
139 case 2: x = x << 2; break;
140 case 3: x = x << 3; break;
141 case 4: x = x << 4; break;
142 case 5: x = x << 5; break;
143 case 6: x = x << 6; break;
144 case 7: x = x << 7; break;
145 case 8: x = x << 8; break;
146 case 9: x = x << 9; break;
147 case 10: x = x << 10; break;
148 case 11: x = x << 11; break;
149 case 12: x = x << 12; break;
150 case 13: x = x << 13; break;
151 case 14: x = x << 14; break;
152 case 15: x = x << 15; break;
153 case 16: x = x << 16; break;
154 case 17: x = x << 17; break;
155 case 18: x = x << 18; break;
156 case 19: x = x << 19; break;
157 case 20: x = x << 20; break;
158 case 21: x = x << 21; break;
159 case 22: x = x << 22; break;
160 case 23: x = x << 23; break;
161 case 24: x = x << 24; break;
162 case 25: x = x << 25; break;
163 case 26: x = x << 26; break;
164 case 27: x = x << 27; break;
165 case 28: x = x << 28; break;
166 case 29: x = x << 29; break;
167 case 30: x = x << 30; break;
168 case 31: x = x << 31; break;
169 #if BITS > 32
170 case 32: x = x << 32; break;
171 case 33: x = x << 33; break;
172 case 34: x = x << 34; break;
173 case 35: x = x << 35; break;
174 case 36: x = x << 36; break;
175 case 37: x = x << 37; break;
176 case 38: x = x << 38; break;
177 case 39: x = x << 39; break;
178 case 40: x = x << 40; break;
179 case 41: x = x << 41; break;
180 case 42: x = x << 42; break;
181 case 43: x = x << 43; break;
182 case 44: x = x << 44; break;
183 case 45: x = x << 45; break;
184 case 46: x = x << 46; break;
185 case 47: x = x << 47; break;
186 case 48: x = x << 48; break;
187 case 49: x = x << 49; break;
188 case 50: x = x << 50; break;
189 case 51: x = x << 51; break;
190 case 52: x = x << 52; break;
191 case 53: x = x << 53; break;
192 case 54: x = x << 54; break;
193 case 55: x = x << 55; break;
194 case 56: x = x << 56; break;
195 case 57: x = x << 57; break;
196 case 58: x = x << 58; break;
197 case 59: x = x << 59; break;
198 case 60: x = x << 60; break;
199 case 61: x = x << 61; break;
200 case 62: x = x << 62; break;
201 case 63: x = x << 63; break;
202 #endif
204 default:
205 ASSERT (0);
207 return x;
209 #endif
210 #endif
212 void
213 testTortureExecute (void)
215 #ifndef __SDCC_pdk14 // Lack of memory
216 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
217 int i;
219 for (i = 0; i < BITS; ++i)
221 unsigned long long y = variable_shift (data[0], i);
222 if (y != data[i])
223 ASSERT (0);
225 for (i = 0; i < BITS; ++i)
227 unsigned long long y = constant_shift (data[0], i);
228 if (y != data[i])
229 ASSERT (0);
231 #endif
232 #endif
233 return;