(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
tree-prof/
indir-call-prof-topn.c
       1  /* { dg-require-profiling "-fprofile-generate" } */
       2  /* { dg-options "-O2 -fdump-ipa-profile_estimate" } */
       3  
       4  #ifdef FOR_AUTOFDO_TESTING
       5  #define MAXITER 350000000
       6  #else
       7  #define MAXITER 3500000
       8  #endif
       9  
      10  #include <stdio.h>
      11  
      12  typedef int (*fptr) (int);
      13  int
      14  one (int a)
      15  {
      16    return 1;
      17  }
      18  
      19  int
      20  two (int a)
      21  {
      22    return 0;
      23  }
      24  
      25  fptr table[] = {&one, &two};
      26  
      27  int
      28  main()
      29  {
      30    int i, x;
      31    fptr p = &one;
      32  
      33    one (3);
      34  
      35    for (i = 0; i < MAXITER; i++)
      36      {
      37        x = (*p) (3);
      38        p = table[x];
      39      }
      40    printf ("done:%d\n", x);
      41  }
      42  
      43  /* { dg-final-use-not-autofdo { scan-ipa-dump "2 \\(200.00%\\) speculations produced." "profile_estimate" } } */