OSDN Git Service

Check in tree-dce enh to trunk
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / cdce1.c
1 /* { dg-do  run } */
2 /* { dg-options "-O2 -fdump-tree-dce1-details  -lm" } */
3 /* { dg-message  "note: function call is shrink-wrapped into error conditions\." "Missing conditional dce" {target "*-*-*"} 15 } */
4  
5 #include <stdlib.h>
6 #include <math.h>
7 #include <errno.h>
8 #include <stdio.h>
9 int total_err_count = 0;
10 double foo_opt(int x, double y) __attribute__((noinline));
11 double foo_opt(int x, double y)
12 {
13     double yy = 0;
14     errno = 0;
15     yy = pow(x,y);
16     return 0;
17 }
18
19 double foo(int x, double y) __attribute__((noinline));
20 double foo(int x, double y)
21 {
22     double yy = 0;
23     errno = 0;
24     yy = pow(x,y);
25     return yy;
26 }
27
28 int test(double (*fp)(int x, double y))
29 {
30    int i,x;
31
32    x = 127; 
33    for (i = 30; i < 300; i++)
34    {  
35       fp(x,i);
36       if (errno)
37          total_err_count ++;
38    }
39
40    x = -300; 
41    for (i = 100; i < 300; i++)
42    {  
43       fp(x,i);
44       if (errno)
45          total_err_count ++;
46    }
47
48    x = 65577;
49    for (i = 60; i < 200; i++)
50    {  
51       fp(x,i);
52       if (errno)
53          total_err_count ++;
54    }
55
56    x = 65577*127;
57    for (i = 1; i < 100; i++)
58    {  
59       fp(x,i);
60       if (errno)
61          total_err_count ++;
62    }
63
64    return total_err_count;
65 }
66
67 int main()
68 {
69   int en1, en2;
70   total_err_count = 0;
71   en1 = test(foo_opt);
72   total_err_count = 0;
73   en2 = test(foo);
74   
75   printf("total number of errors = %d, %d\n", en1, en2);
76   if (en1 != en2)
77      abort();
78
79   return 0;
80
81 }