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-pr63302.c
blob3d9a553418e7d0cc4d74c53bb65c7b350f603a16
1 /*
2 pr63302.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 /* PR tree-optimization/63302 */
13 #if LLONG_MAX == 9223372036854775807ll
14 #define USE_LLONG
15 #endif
17 #ifdef USE_INT128
18 __attribute__((noinline, noclone)) int
19 foo (__int128 x)
21 __int128 v = x & (((__int128) -1 << 63) | 0x7ff);
23 return v == 0 || v == ((__int128) -1 << 63);
25 #endif
27 #ifdef USE_LLONG
28 __attribute__((noinline, noclone)) int
29 bar (long long x)
31 long long v = x & (((long long) -1 << 31) | 0x7ff);
33 return v == 0 || v == ((long long) -1 << 31);
35 #endif
37 void
38 testTortureExecute (void)
40 #ifdef USE_INT128
41 if (foo (0) != 1
42 || foo (1) != 0
43 || foo (0x800) != 1
44 || foo (0x801) != 0
45 || foo ((__int128) 1 << 63) != 0
46 || foo ((__int128) -1 << 63) != 1
47 || foo (((__int128) -1 << 63) | 1) != 0
48 || foo (((__int128) -1 << 63) | 0x800) != 1
49 || foo (((__int128) -1 << 63) | 0x801) != 0)
50 ASSERT (0);
51 #endif
52 #ifdef USE_LLONG
53 if (bar (0) != 1
54 || bar (1) != 0
55 || bar (0x800) != 1
56 || bar (0x801) != 0
57 || bar (1LL << 31) != 0
58 || bar (-1LL << 31) != 1
59 || bar ((-1LL << 31) | 1) != 0
60 || bar ((-1LL << 31) | 0x800) != 1
61 || bar ((-1LL << 31) | 0x801) != 0)
62 ASSERT (0);
63 #endif
64 return;