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-20020615-1.c
blob4c7844303f8d6fdc2e285f3b78ad3e943f1fd2cb
1 /*
2 20020615-1.c from the execute part of the gcc torture suite.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 /* PR target/7042. When reorg.c changed branches into return insns, it
12 completely forgot about any current_function_epilogue_delay_list and
13 dropped those insns. Uncovered on cris-axis-elf, where an insn in an
14 epilogue delay-slot set the return-value register with the testcase
15 below. Derived from ghostscript-6.52 (GPL) by hp@axis.com. */
17 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pic14)// Lack of memory
18 typedef struct font_hints_s {
19 int axes_swapped;
20 int x_inverted, y_inverted;
21 } font_hints;
22 typedef struct gs_fixed_point_s {
23 long x, y;
24 } gs_fixed_point;
26 int
27 line_hints(const font_hints *fh, const gs_fixed_point *p0,
28 const gs_fixed_point *p1)
30 long dx = p1->x - p0->x;
31 long dy = p1->y - p0->y;
32 long adx, ady;
33 int xi = fh->x_inverted, yi = fh->y_inverted;
34 int hints;
35 if (xi)
36 dx = -dx;
37 if (yi)
38 dy = -dy;
39 if (fh->axes_swapped) {
40 long t = dx;
41 int ti = xi;
42 dx = dy, xi = yi;
43 dy = t, yi = ti;
45 adx = dx < 0 ? -dx : dx;
46 ady = dy < 0 ? -dy : dy;
47 if (dy != 0 && (adx <= ady >> 4)) {
48 hints = dy > 0 ? 2 : 1;
49 if (xi)
50 hints ^= 3;
51 } else if (dx != 0 && (ady <= adx >> 4)) {
52 hints = dx < 0 ? 8 : 4;
53 if (yi)
54 hints ^= 12;
55 } else
56 hints = 0;
57 return hints;
59 #endif
60 void
61 testTortureExecute (void)
63 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pic14)// Lack of memory
64 static font_hints fh[] = {{0, 1, 0}, {0, 0, 1}, {0, 0, 0}};
65 static gs_fixed_point gsf[]
66 = {{0x30000, 0x13958}, {0x30000, 0x18189},
67 {0x13958, 0x30000}, {0x18189, 0x30000}};
68 if (line_hints (fh, gsf, gsf + 1) != 1
69 || line_hints (fh + 1, gsf + 2, gsf + 3) != 8
70 || line_hints (fh + 2, gsf + 2, gsf + 3) != 4)
71 ASSERT (0);
72 return;
73 #endif