1 /*
2 pr47337.c from the execute part of the gcc torture tests.
3 */
4
5 #include <testfwk.h>
6
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
10
11 #include <string.h>
12
13 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pic14) && !defined(__SDCC_pic16) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
14
15 /* PR rtl-optimization/47337 */
16
17 static unsigned int a[256], b = 0;
18 static char c = 0;
19 static int d = 0, *f = &d;
20 static long long e = 0;
21
22 static short
foo(long long x,long long y)23 foo (long long x, long long y)
24 {
25 return x / y;
26 }
27
28 static char
bar(char x,char y)29 bar (char x, char y)
30 {
31 return x - y;
32 }
33
34 static int
baz(int x,int y)35 baz (int x, int y)
36 {
37 *f = (y != (short) (y * 3));
38 for (c = 0; c < 2; c++)
39 {
40 lab:
41 if (d)
42 {
43 if (e)
44 e = 1;
45 else
46 return x;
47 }
48 else
49 {
50 d = 1;
51 goto lab;
52 }
53 f = &d;
54 }
55 return x;
56 }
57
58 static void
fnx(unsigned long long x,int y)59 fnx (unsigned long long x, int y)
60 {
61 if (!y)
62 {
63 b = a[b & 1];
64 b = a[b & 1];
65 b = a[(b ^ (x & 1)) & 1];
66 b = a[(b ^ (x & 1)) & 1];
67 }
68 }
69
70 const char *volatile w = "2";
71 #endif
72
73 void
testTortureExecute(void)74 testTortureExecute (void)
75 {
76 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pic14) && !defined(__SDCC_pic16) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
77 int h = 0;
78 unsigned int k = 0;
79 int l[8];
80 int i, j;
81
82 if (strcmp (w, "1") == 0)
83 h = 1;
84
85 for (i = 0; i < 256; i++)
86 {
87 for (j = 8; j > 0; j--)
88 k = 1;
89 a[i] = k;
90 }
91 for (i = 0; i < 8; i++)
92 l[i] = 0;
93
94 d = bar (c, c);
95 d = baz (c, 1 | foo (l[0], 10));
96 fnx (d, h);
97 fnx (e, h);
98
99 if (d != 0)
100 ASSERT (0);
101 return;
102 #endif
103 }
104
105