Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/20031201-1.c

raw
1 /* Copyright (C) 2003 Free Software Foundation.
2 PR target/13256
3 STRICT_LOW_PART was handled incorrectly in delay slots.
4 Origin: Hans-Peter Nilsson. */
5
6 void abort (void);
7 void exit (int);
8
9 typedef struct { unsigned int e0 : 16; unsigned int e1 : 16; } s1;
10 typedef struct { unsigned int e0 : 16; unsigned int e1 : 16; } s2;
11 typedef struct { s1 i12; s2 i16; } io;
12 static int test_length = 2;
13 static io *i;
14 static int m = 1;
15 static int d = 1;
16 static unsigned long test_t0;
17 static unsigned long test_t1;
18 void test(void) __attribute__ ((__noinline__));
19 extern int f1 (void *port) __attribute__ ((__noinline__));
20 extern void f0 (void) __attribute__ ((__noinline__));
21 int
22 f1 (void *port)
23 {
24 int fail_count = 0;
25 unsigned long tlen;
26 s1 x0 = {0};
27 s2 x1 = {0};
28
29 i = port;
30 x0.e0 = x1.e0 = 32;
31 i->i12 = x0;
32 i->i16 = x1;
33 do f0(); while (test_t1);
34 x0.e0 = x1.e0 = 8;
35 i->i12 = x0;
36 i->i16 = x1;
37 test ();
38 if (m)
39 {
40 unsigned long e = 1000000000 / 460800 * test_length;
41 tlen = test_t1 - test_t0;
42 if (((tlen-e) & 0x7FFFFFFF) > 1000)
43 f0();
44 }
45 if (d)
46 {
47 unsigned long e = 1000000000 / 460800 * test_length;
48 tlen = test_t1 - test_t0;
49 if (((tlen - e) & 0x7FFFFFFF) > 1000)
50 f0();
51 }
52 return fail_count != 0 ? 1 : 0;
53 }
54
55 int
56 main ()
57 {
58 io io0;
59 f1 (&io0);
60 abort ();
61 }
62
63 void
64 test (void)
65 {
66 io *iop = i;
67 if (iop->i12.e0 != 8 || iop->i16.e0 != 8)
68 abort ();
69 exit (0);
70 }
71
72 void
73 f0 (void)
74 {
75 static int washere = 0;
76 io *iop = i;
77 if (washere++ || iop->i12.e0 != 32 || iop->i16.e0 != 32)
78 abort ();
79 }