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-pr89634.c
blobd13a5d7d9446803011d45469be0e21fab99c718b
1 /*
2 pr37125.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #include <limits.h>
9 /* PR rtl-optimization/89634 */
11 static unsigned long *
12 foo (unsigned long *x)
14 return x + (1 + *x);
17 #if !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
18 unsigned long
19 bar (unsigned long *x)
21 unsigned long c, d = 1, e, *f, g, h = 0, i;
22 for (e = *x - 1; e > 0; e--)
24 f = foo (x + 1);
25 for (i = 1; i < e; i++)
26 f = foo (f);
27 c = *f;
28 if (c == 2)
29 d *= 2;
30 else
32 i = (c - 1) / 2 - 1;
33 g = (2 * i + 1) * (d + 1) + (2 * d + 1);
34 if (g > h)
35 h = g;
36 d *= c;
39 return h;
41 #endif
43 void
44 testTortureExecute (void)
46 #if !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
47 unsigned long a[18] = { 4, 2, -200, 200, 2, -400, 400, 3, -600, 0, 600, 5, -100, -66, 0, 66, 100, LONG_MAX / 8 + 1 };
48 if (bar (a) != 17)
49 ASSERT (0);
50 return;
51 #endif