summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.hp/optimize.c
blob: 2a8daa8c7a07c267e76f4c63ad7e28b5d58770b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* Source for debugging optimimzed code test.

    cc -g -O -o optimize optimize.c
*/
int callee();
int test_opt;

int main()
{
   int a,b,c,d,e,f,g,h;

   a = 10;;

   /* Value propagate
    */
   b = 2 * a + 1;
   c = 3 * b + 2;

   /* Re-use expressions
    */
   d = (2 * a + 1) * (3 * b + 2);
   e = (2 * a + 1) * (3 * b + 2);

   /* Create dead stores--do lines still exist?
    */
   d = (2 * a + 1) * (3 * b + 2);
   e = (2 * a + 1) * (3 * b + 2);
   d = (2 * a + 1) * (3 * b + 2);
   e = (2 * a + 1) * (3 * b + 2);

   /* Alpha and psi motion
    */
   if( test_opt ) {
       f = e - d;
       f = f--;
   }
   else {
       f = e - d;
       f = f + d * e;
   }

   /* Chi and Rho motion
    */
   h = 0;
   do {
       h++;
       a = b * c + d * e;  /* Chi */
       f = f + d * e;
       g = f + d * e;      /* Rho */
       callee( g+1 );
       test_opt = (test_opt != 1);  /* Cycles */
   } while( g && h < 10);

   /* Opps for tail recursion, unrolling,
    * folding, evaporating
    */
   for( a = 0; a < 100; a++ ) {
       callee( callee ( callee( a )));
       callee( callee ( callee( a )));
       callee( callee ( callee( a )));
   }

   return callee( test_opt );
}

/* defined late to keep line numbers the same
*/
int callee( x )
    int x;      /* not used! */
{
    test_opt++; /* side effect */

    return test_opt;
}

/* end */