(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
predict-18.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-O2 -fdump-tree-profile_estimate" } */
       3  
       4  extern int global;
       5  
       6  int x;
       7  
       8  short v = 0;
       9  short expected = 0;
      10  short max = ~0;
      11  #define STRONG 0
      12  
      13  void foo (int a, int b)
      14  {
      15    if (__builtin_expect_with_probability (a < b, 1, 0.6f) > __builtin_expect (b, 0))
      16      global++;
      17  
      18    if (__builtin_expect_with_probability (a < b, 1, 0.777f) > 0)
      19      global++;
      20  
      21    if (__builtin_expect_with_probability (a < b, 1, 0.99) == __atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED))
      22      global++;
      23  
      24    if (__builtin_expect_with_probability (a < 10, 1, 0.9f) > __builtin_expect_with_probability (b, 0, 0.8f))
      25      global++;
      26  }
      27  
      28  /* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 54.00%" "profile_estimate"} } */
      29  /* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 77.70%" "profile_estimate"} } */
      30  /* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 98.96%" "profile_estimate"} } */
      31  /* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 71.99%" "profile_estimate"} } */