1 /* { dg-do run } */ 2 /* { dg-skip-if "doubles are floats" { "avr-*-*" } { "*" } { "" } } */ 3 /* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details -lm" } */ 4 /* { dg-final { scan-tree-dump "cdce2.c:16: note: function call is shrink-wrapped into error conditions\." "cdce" } }*/ 5 /* { dg-final { cleanup-tree-dump "cdce" } } */ 6 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)); foo_opt(double y)12double foo_opt (double y) 13 { 14 double yy = 0; 15 errno = 0; 16 yy = log (y); 17 return 0; 18 } 19 20 double foo (double y) __attribute__((noinline)); foo(double y)21double foo (double y) 22 { 23 double yy = 0; 24 errno = 0; 25 yy = log (y); 26 return yy; 27 } 28 test(double (* fp)(double y))29int test (double (*fp) (double y)) 30 { 31 int i,x; 32 for (i = -100; i < 100; i++) 33 { 34 fp (i); 35 if (errno) 36 total_err_count ++; 37 } 38 39 return total_err_count; 40 } 41 main()42int main () 43 { 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); 50 51 if (en1 != en2) 52 abort(); 53 54 return 0; 55 } 56