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