Debian Codegraph @

gcc/testsuite/gcc.dg/predict-18.c

raw
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 short m = 0;
12 short n = 0;
13 #define STRONG 0
14
15 void foo (int a, int b)
16 {
17 if (__builtin_expect_with_probability (a < b, 1, 0.6f) > __builtin_expect (b, 0))
18 global++;
19
20 if (__builtin_expect_with_probability (a < b, 1, 0.777f) > 0)
21 global++;
22
23 if (__builtin_expect_with_probability (a < b, 1, 0.99) == __atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED))
24 global++;
25
26 if (__builtin_expect_with_probability (a < 10, 1, 0.9f) > __builtin_expect_with_probability (b, 0, 0.8f))
27 global++;
28
29 if (a * __builtin_expect_with_probability (m, 0, 0.6f) > 0)
30 global++;
31
32 if (__builtin_expect_with_probability (n, 0, 0.65f) * a > 0)
33 global++;
34 }
35
36 /* { dg-final { scan-tree-dump "combined value predictions heuristics of edge .*->.*: 54.00%" "profile_estimate"} } */
37 /* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 77.70%" "profile_estimate"} } */
38 /* { dg-final { scan-tree-dump "combined value predictions heuristics of edge .*->.*: 98.96%" "profile_estimate"} } */
39 /* { dg-final { scan-tree-dump "combined value predictions heuristics of edge .*->.*: 71.99%" "profile_estimate"} } */
40 /* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 40.00%" "profile_estimate"} } */
41 /* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 35.01%" "profile_estimate"} } */