2 20020506-1.c from the execute part of the gcc torture suite.
11 #if !defined(__SDCC_pic14) && !defined(__SDCC_pic16) && !defined(__SDCC_pdk14)
12 /* Copyright (C) 2002 Free Software Foundation.
14 Test that (A & C1) op C2 optimizations behave correctly where C1 is
15 a constant power of 2, op is == or !=, and C2 is C1 or zero.
17 Written by Roger Sayle, 5th May 2002. */
21 void fest1 (signed char c
, int set
);
22 void fest2 (unsigned char c
, int set
);
23 void fest3 (short s
, int set
);
24 void fest4 (unsigned short s
, int set
);
25 void fest5 (int i
, int set
);
26 void fest6 (unsigned int i
, int set
);
27 void fest7 (long long l
, int set
);
28 void fest8 (unsigned long long l
, int set
);
31 #define LONG_LONG_MAX LLONG_MAX
34 #define LONG_LONG_MIN (-LONG_LONG_MAX-1)
36 #ifndef ULONG_LONG_MAX
37 #define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1)
42 fest1 (signed char c
, int set
)
44 if ((c
& (SCHAR_MAX
+1)) == 0)
51 if ((c
& (SCHAR_MAX
+1)) != 0)
58 if ((unsigned char) (c
& (SCHAR_MAX
+1)) == (SCHAR_MAX
+1))
65 if ((unsigned char) (c
& (SCHAR_MAX
+1)) != (SCHAR_MAX
+1))
74 fest2 (unsigned char c
, int set
)
76 if ((c
& (SCHAR_MAX
+1)) == 0)
83 if ((c
& (SCHAR_MAX
+1)) != 0)
90 if ((c
& (SCHAR_MAX
+1)) == (SCHAR_MAX
+1))
97 if ((c
& (SCHAR_MAX
+1)) != (SCHAR_MAX
+1))
102 if (!set
) ASSERT (0);
106 fest3 (short s
, int set
)
108 if ((s
& (SHRT_MAX
+1)) == 0)
113 if (!set
) ASSERT (0);
115 if ((s
& (SHRT_MAX
+1)) != 0)
117 if (!set
) ASSERT (0);
122 if ((s
& (SHRT_MAX
+1)) == (SHRT_MAX
+1))
124 if (!set
) ASSERT (0);
129 if ((s
& (SHRT_MAX
+1)) != (SHRT_MAX
+1))
134 if (!set
) ASSERT (0);
138 fest4 (unsigned short s
, int set
)
140 if ((s
& (SHRT_MAX
+1)) == 0)
145 if (!set
) ASSERT (0);
147 if ((s
& (SHRT_MAX
+1)) != 0)
149 if (!set
) ASSERT (0);
154 if ((s
& (SHRT_MAX
+1)) == (SHRT_MAX
+1))
156 if (!set
) ASSERT (0);
161 if ((s
& (SHRT_MAX
+1)) != (SHRT_MAX
+1))
166 if (!set
) ASSERT (0);
168 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
170 fest5 (int i
, int set
)
172 if ((i
& (INT_MAX
+1U)) == 0)
177 if (!set
) ASSERT (0);
179 if ((i
& (INT_MAX
+1U)) != 0)
181 if (!set
) ASSERT (0);
186 if ((i
& (INT_MAX
+1U)) == (INT_MAX
+1U))
188 if (!set
) ASSERT (0);
193 if ((i
& (INT_MAX
+1U)) != (INT_MAX
+1U))
198 if (!set
) ASSERT (0);
202 fest6 (unsigned int i
, int set
)
204 if ((i
& (INT_MAX
+1U)) == 0)
209 if (!set
) ASSERT (0);
211 if ((i
& (INT_MAX
+1U)) != 0)
213 if (!set
) ASSERT (0);
218 if ((i
& (INT_MAX
+1U)) == (INT_MAX
+1U))
220 if (!set
) ASSERT (0);
225 if ((i
& (INT_MAX
+1U)) != (INT_MAX
+1U))
230 if (!set
) ASSERT (0);
234 fest7 (long long l
, int set
)
236 if ((l
& (LONG_LONG_MAX
+1ULL)) == 0)
241 if (!set
) ASSERT (0);
243 if ((l
& (LONG_LONG_MAX
+1ULL)) != 0)
245 if (!set
) ASSERT (0);
250 if ((l
& (LONG_LONG_MAX
+1ULL)) == (LONG_LONG_MAX
+1ULL))
257 if ((l
& (LONG_LONG_MAX
+1ULL)) != (LONG_LONG_MAX
+1ULL))
266 fest8 (unsigned long long l
, int set
)
268 if ((l
& (LONG_LONG_MAX
+1ULL)) == 0)
273 if (!set
) ASSERT (0);
275 if ((l
& (LONG_LONG_MAX
+1ULL)) != 0)
277 if (!set
) ASSERT (0);
282 if ((l
& (LONG_LONG_MAX
+1ULL)) == (LONG_LONG_MAX
+1ULL))
284 if (!set
) ASSERT (0);
289 if ((l
& (LONG_LONG_MAX
+1ULL)) != (LONG_LONG_MAX
+1ULL))
294 if (!set
) ASSERT (0);
300 testTortureExecute (void)
302 #if !defined(__SDCC_pic14) && !defined(__SDCC_pic16) && !defined(__SDCC_pdk14)
304 fest1 (SCHAR_MAX
, 0);
305 fest1 (SCHAR_MIN
, 1);
306 fest1 (UCHAR_MAX
, 1);
309 fest2 (SCHAR_MAX
, 0);
310 fest2 (SCHAR_MIN
, 1);
311 fest2 (UCHAR_MAX
, 1);
316 fest3 (USHRT_MAX
, 1);
321 fest4 (USHRT_MAX
, 1);
322 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
334 fest7 (LONG_LONG_MAX
, 0);
335 fest7 (LONG_LONG_MIN
, 1);
336 fest7 (ULONG_LONG_MAX
, 1);
339 fest8 (LONG_LONG_MAX
, 0);
340 fest8 (LONG_LONG_MIN
, 1);
341 fest8 (ULONG_LONG_MAX
, 1);