2008-06-04 Xinliang David Li <davidxl@google.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / cdce2.c
blobba9e4962050fa71f455be608e789e794dc3b3bc2
1 /* { dg-do run { target { ! "*-*-darwin" } } } */
2 /* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details -lm" } */
3 /* { dg-final { scan-tree-dump "cdce2.c:16: note: function call is shrink-wrapped into error conditions\." "cdce" } }*/
4 /* { dg-final { cleanup-tree-dump "cdce" } } */
7 #include <stdlib.h>
8 #include <math.h>
9 #include <errno.h>
10 int total_err_count = 0;
11 double foo_opt (double y) __attribute__((noinline));
12 double foo_opt (double y)
14 double yy = 0;
15 errno = 0;
16 yy = log (y);
17 return 0;
20 double foo (double y) __attribute__((noinline));
21 double foo (double y)
23 double yy = 0;
24 errno = 0;
25 yy = log (y);
26 return yy;
29 int test (double (*fp) (double y))
31 int i,x;
32 for (i = -100; i < 100; i++)
34 fp (i);
35 if (errno)
36 total_err_count ++;
39 return total_err_count;
42 int main ()
44 int en1, en2;
45 double yy;
46 total_err_count = 0;
47 en1 = test (foo_opt);
48 total_err_count = 0;
49 en2 = test (foo);
51 if (en1 != en2)
52 abort();
54 return 0;