Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-lshrdi-1.c
blob2111f1f02c0efb81fc9dda8c6f0b6a8e2c3cbf93
1 /*
2 lshrdi-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #include <limits.h>
9 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
10 #if !(defined(__SDCC_mcs51) && (defined(__SDCC_MODEL_SMALL) || defined(__SDCC_MODEL_MEDIUM) || defined(__SDCC_MODEL_LARGE) && defined(__SDCC_STACK_AUTO))) && !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) // Lack of memory
12 #if LLONG_MAX == 9223372036854775807LL
13 #define BITS 64
15 static unsigned long long const zext[64] = {
16 0x87654321fedcba90ULL,
17 0x43b2a190ff6e5d48ULL,
18 0x21d950c87fb72ea4ULL,
19 0x10eca8643fdb9752ULL,
20 0x87654321fedcba9ULL,
21 0x43b2a190ff6e5d4ULL,
22 0x21d950c87fb72eaULL,
23 0x10eca8643fdb975ULL,
24 0x87654321fedcbaULL,
25 0x43b2a190ff6e5dULL,
26 0x21d950c87fb72eULL,
27 0x10eca8643fdb97ULL,
28 0x87654321fedcbULL,
29 0x43b2a190ff6e5ULL,
30 0x21d950c87fb72ULL,
31 0x10eca8643fdb9ULL,
32 0x87654321fedcULL,
33 0x43b2a190ff6eULL,
34 0x21d950c87fb7ULL,
35 0x10eca8643fdbULL,
36 0x87654321fedULL,
37 0x43b2a190ff6ULL,
38 0x21d950c87fbULL,
39 0x10eca8643fdULL,
40 0x87654321feULL,
41 0x43b2a190ffULL,
42 0x21d950c87fULL,
43 0x10eca8643fULL,
44 0x87654321fULL,
45 0x43b2a190fULL,
46 0x21d950c87ULL,
47 0x10eca8643ULL,
48 0x87654321ULL,
49 0x43b2a190ULL,
50 0x21d950c8ULL,
51 0x10eca864ULL,
52 0x8765432ULL,
53 0x43b2a19ULL,
54 0x21d950cULL,
55 0x10eca86ULL,
56 0x876543ULL,
57 0x43b2a1ULL,
58 0x21d950ULL,
59 0x10eca8ULL,
60 0x87654ULL,
61 0x43b2aULL,
62 0x21d95ULL,
63 0x10ecaULL,
64 0x8765ULL,
65 0x43b2ULL,
66 0x21d9ULL,
67 0x10ecULL,
68 0x876ULL,
69 0x43bULL,
70 0x21dULL,
71 0x10eULL,
72 0x87ULL,
73 0x43ULL,
74 0x21ULL,
75 0x10ULL,
76 0x8ULL,
77 0x4ULL,
78 0x2ULL,
79 0x1ULL
82 #elif LLONG_MAX == 2147483647LL
83 #define BITS 32
85 static unsigned long long const zext[32] = {
86 0x87654321ULL,
87 0x43b2a190ULL,
88 0x21d950c8ULL,
89 0x10eca864ULL,
90 0x8765432ULL,
91 0x43b2a19ULL,
92 0x21d950cULL,
93 0x10eca86ULL,
94 0x876543ULL,
95 0x43b2a1ULL,
96 0x21d950ULL,
97 0x10eca8ULL,
98 0x87654ULL,
99 0x43b2aULL,
100 0x21d95ULL,
101 0x10ecaULL,
102 0x8765ULL,
103 0x43b2ULL,
104 0x21d9ULL,
105 0x10ecULL,
106 0x876ULL,
107 0x43bULL,
108 0x21dULL,
109 0x10eULL,
110 0x87ULL,
111 0x43ULL,
112 0x21ULL,
113 0x10ULL,
114 0x8ULL,
115 0x4ULL,
116 0x2ULL,
117 0x1ULL,
120 #else
121 #error "Update the test case."
122 #endif
124 static unsigned long long
125 variable_shift(unsigned long long x, int i)
127 return x >> i;
130 static unsigned long long
131 constant_shift(unsigned long long x, int i)
133 switch (i)
135 case 0: x = x >> 0; break;
136 case 1: x = x >> 1; break;
137 case 2: x = x >> 2; break;
138 case 3: x = x >> 3; break;
139 case 4: x = x >> 4; break;
140 case 5: x = x >> 5; break;
141 case 6: x = x >> 6; break;
142 case 7: x = x >> 7; break;
143 case 8: x = x >> 8; break;
144 case 9: x = x >> 9; break;
145 case 10: x = x >> 10; break;
146 case 11: x = x >> 11; break;
147 case 12: x = x >> 12; break;
148 case 13: x = x >> 13; break;
149 case 14: x = x >> 14; break;
150 case 15: x = x >> 15; break;
151 case 16: x = x >> 16; break;
152 case 17: x = x >> 17; break;
153 case 18: x = x >> 18; break;
154 case 19: x = x >> 19; break;
155 case 20: x = x >> 20; break;
156 case 21: x = x >> 21; break;
157 case 22: x = x >> 22; break;
158 case 23: x = x >> 23; break;
159 case 24: x = x >> 24; break;
160 case 25: x = x >> 25; break;
161 case 26: x = x >> 26; break;
162 case 27: x = x >> 27; break;
163 case 28: x = x >> 28; break;
164 case 29: x = x >> 29; break;
165 case 30: x = x >> 30; break;
166 case 31: x = x >> 31; break;
167 #if BITS > 32
168 case 32: x = x >> 32; break;
169 case 33: x = x >> 33; break;
170 case 34: x = x >> 34; break;
171 case 35: x = x >> 35; break;
172 case 36: x = x >> 36; break;
173 case 37: x = x >> 37; break;
174 case 38: x = x >> 38; break;
175 case 39: x = x >> 39; break;
176 case 40: x = x >> 40; break;
177 case 41: x = x >> 41; break;
178 case 42: x = x >> 42; break;
179 case 43: x = x >> 43; break;
180 case 44: x = x >> 44; break;
181 case 45: x = x >> 45; break;
182 case 46: x = x >> 46; break;
183 case 47: x = x >> 47; break;
184 case 48: x = x >> 48; break;
185 case 49: x = x >> 49; break;
186 case 50: x = x >> 50; break;
187 case 51: x = x >> 51; break;
188 case 52: x = x >> 52; break;
189 case 53: x = x >> 53; break;
190 case 54: x = x >> 54; break;
191 case 55: x = x >> 55; break;
192 case 56: x = x >> 56; break;
193 case 57: x = x >> 57; break;
194 case 58: x = x >> 58; break;
195 case 59: x = x >> 59; break;
196 case 60: x = x >> 60; break;
197 case 61: x = x >> 61; break;
198 case 62: x = x >> 62; break;
199 case 63: x = x >> 63; break;
200 #endif
202 default:
203 ASSERT (0);
205 return x;
207 #endif
208 #endif
210 void
211 testTortureExecute (void)
213 #if !(defined(__SDCC_mcs51) && (defined(__SDCC_MODEL_SMALL) || defined(__SDCC_MODEL_MEDIUM) || defined(__SDCC_MODEL_LARGE) && defined(__SDCC_STACK_AUTO))) && !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) // Lack of memory
214 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
215 int i;
217 for (i = 0; i < BITS; ++i)
219 unsigned long long y = variable_shift (zext[0], i);
220 if (y != zext[i])
221 ASSERT (0);
223 for (i = 0; i < BITS; ++i)
225 unsigned long long y = constant_shift (zext[0], i);
226 if (y != zext[i])
227 ASSERT (0);
229 #endif
230 #endif
231 return;