Mercurial > hg > CbC > CbC_gcc
comparison gcc/predict.def @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Definitions for the branch prediction routines in the GNU compiler. | 1 /* Definitions for the branch prediction routines in the GNU compiler. |
2 Copyright (C) 2001-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2001-2018 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GCC. | 4 This file is part of GCC. |
5 | 5 |
6 GCC is free software; you can redistribute it and/or modify it under | 6 GCC is free software; you can redistribute it and/or modify it under |
7 the terms of the GNU General Public License as published by the Free | 7 the terms of the GNU General Public License as published by the Free |
20 /* Before including this file, you should define a macro: | 20 /* Before including this file, you should define a macro: |
21 | 21 |
22 DEF_PREDICTOR (ENUM, NAME, HITRATE) | 22 DEF_PREDICTOR (ENUM, NAME, HITRATE) |
23 | 23 |
24 This macro will be called once for each predictor. The ENUM will | 24 This macro will be called once for each predictor. The ENUM will |
25 be of type `enum predictor', and will enumerate all supported | 25 be of type `enum br_predictor', and will enumerate all supported |
26 predictors. The order of DEF_PREDICTOR calls is important, as | 26 predictors. The order of DEF_PREDICTOR calls is important, as |
27 in the first match combining heuristics, the predictor appearing | 27 in the first match combining heuristics, the predictor appearing |
28 first in this file will win. | 28 first in this file will win. |
29 | 29 |
30 NAME is used in the debugging output to determine predictor type. | 30 NAME is used in the debugging output to determine predictor type. |
49 | 49 |
50 /* Mark unconditional jump as taken. */ | 50 /* Mark unconditional jump as taken. */ |
51 DEF_PREDICTOR (PRED_UNCONDITIONAL, "unconditional jump", PROB_ALWAYS, | 51 DEF_PREDICTOR (PRED_UNCONDITIONAL, "unconditional jump", PROB_ALWAYS, |
52 PRED_FLAG_FIRST_MATCH) | 52 PRED_FLAG_FIRST_MATCH) |
53 | 53 |
54 /* Return value of malloc function is almost always non-null. */ | |
55 DEF_PREDICTOR (PRED_MALLOC_NONNULL, "malloc returned non-NULL", \ | |
56 PROB_VERY_LIKELY, PRED_FLAG_FIRST_MATCH) | |
57 | |
54 /* Use number of loop iterations determined by # of iterations | 58 /* Use number of loop iterations determined by # of iterations |
55 analysis to set probability. We don't want to use Dempster-Shaffer | 59 analysis to set probability. We don't want to use Dempster-Shaffer |
56 theory here, as the predictions is exact. */ | 60 theory here, as the predictions is exact. */ |
57 DEF_PREDICTOR (PRED_LOOP_ITERATIONS, "loop iterations", PROB_ALWAYS, | 61 DEF_PREDICTOR (PRED_LOOP_ITERATIONS, "loop iterations", PROB_UNINITIALIZED, |
58 PRED_FLAG_FIRST_MATCH) | 62 PRED_FLAG_FIRST_MATCH) |
59 | 63 |
60 /* Assume that any given atomic operation has low contention, | 64 /* Assume that any given atomic operation has low contention, |
61 and thus the compare-and-swap operation succeeds. */ | 65 and thus the compare-and-swap operation succeeds. */ |
62 DEF_PREDICTOR (PRED_COMPARE_AND_SWAP, "compare and swap", PROB_VERY_LIKELY, | 66 DEF_PREDICTOR (PRED_COMPARE_AND_SWAP, "compare and swap", PROB_VERY_LIKELY, |
67 builtin_expect_probability with a default value of HITRATE(90). | 71 builtin_expect_probability with a default value of HITRATE(90). |
68 Refer to param.def for details. */ | 72 Refer to param.def for details. */ |
69 DEF_PREDICTOR (PRED_BUILTIN_EXPECT, "__builtin_expect", PROB_VERY_LIKELY, | 73 DEF_PREDICTOR (PRED_BUILTIN_EXPECT, "__builtin_expect", PROB_VERY_LIKELY, |
70 PRED_FLAG_FIRST_MATCH) | 74 PRED_FLAG_FIRST_MATCH) |
71 | 75 |
76 /* Hints provided by user via __builtin_expect_with_probability. */ | |
77 DEF_PREDICTOR (PRED_BUILTIN_EXPECT_WITH_PROBABILITY, | |
78 "__builtin_expect_with_probability", PROB_UNINITIALIZED, | |
79 PRED_FLAG_FIRST_MATCH) | |
80 | |
72 /* Use number of loop iterations guessed by the contents of the loop. */ | 81 /* Use number of loop iterations guessed by the contents of the loop. */ |
73 DEF_PREDICTOR (PRED_LOOP_ITERATIONS_GUESSED, "guessed loop iterations", | 82 DEF_PREDICTOR (PRED_LOOP_ITERATIONS_GUESSED, "guessed loop iterations", |
74 PROB_ALWAYS, PRED_FLAG_FIRST_MATCH) | 83 PROB_UNINITIALIZED, PRED_FLAG_FIRST_MATCH) |
75 | 84 |
76 /* Use number of loop iterations guessed by the contents of the loop. */ | 85 /* Use number of loop iterations guessed by the contents of the loop. */ |
77 DEF_PREDICTOR (PRED_LOOP_ITERATIONS_MAX, "guessed loop iterations", | 86 DEF_PREDICTOR (PRED_LOOP_ITERATIONS_MAX, "guessed loop iterations", |
78 PROB_ALWAYS, PRED_FLAG_FIRST_MATCH) | 87 PROB_UNINITIALIZED, PRED_FLAG_FIRST_MATCH) |
79 | 88 |
80 /* Branch containing goto is probably not taken. */ | 89 /* Branch containing goto is probably not taken. */ |
81 DEF_PREDICTOR (PRED_CONTINUE, "continue", HITRATE (67), 0) | 90 DEF_PREDICTOR (PRED_CONTINUE, "continue", HITRATE (67), 0) |
82 | 91 |
83 /* Branch to basic block containing call marked by noreturn attribute. */ | 92 /* Branch to basic block containing call marked by noreturn attribute. */ |
87 /* Branch to basic block containing call marked by cold function attribute. */ | 96 /* Branch to basic block containing call marked by cold function attribute. */ |
88 DEF_PREDICTOR (PRED_COLD_FUNCTION, "cold function call", PROB_VERY_LIKELY, | 97 DEF_PREDICTOR (PRED_COLD_FUNCTION, "cold function call", PROB_VERY_LIKELY, |
89 PRED_FLAG_FIRST_MATCH) | 98 PRED_FLAG_FIRST_MATCH) |
90 | 99 |
91 /* Edge causing loop to terminate is probably not taken. */ | 100 /* Edge causing loop to terminate is probably not taken. */ |
92 DEF_PREDICTOR (PRED_LOOP_EXIT, "loop exit", HITRATE (85), | 101 DEF_PREDICTOR (PRED_LOOP_EXIT, "loop exit", HITRATE (89), |
93 PRED_FLAG_FIRST_MATCH) | 102 PRED_FLAG_FIRST_MATCH) |
94 | 103 |
95 /* Same as LOOP_EXIT but for loops containing recursive call. */ | 104 /* Same as LOOP_EXIT but for loops containing recursive call. */ |
96 DEF_PREDICTOR (PRED_LOOP_EXIT_WITH_RECURSION, "loop exit with recursion", | 105 DEF_PREDICTOR (PRED_LOOP_EXIT_WITH_RECURSION, "loop exit with recursion", |
97 HITRATE (72), PRED_FLAG_FIRST_MATCH) | 106 HITRATE (78), PRED_FLAG_FIRST_MATCH) |
98 | 107 |
99 /* Edge causing loop to terminate by computing value used by later | 108 /* Edge causing loop to terminate by computing value used by later |
100 conditional. */ | 109 conditional. */ |
101 DEF_PREDICTOR (PRED_LOOP_EXTRA_EXIT, "extra loop exit", HITRATE (83), | 110 DEF_PREDICTOR (PRED_LOOP_EXTRA_EXIT, "extra loop exit", HITRATE (67), |
102 PRED_FLAG_FIRST_MATCH) | 111 PRED_FLAG_FIRST_MATCH) |
103 | 112 |
104 /* Pointers are usually not NULL. */ | 113 /* Pointers are usually not NULL. */ |
105 DEF_PREDICTOR (PRED_POINTER, "pointer", HITRATE (70), 0) | 114 DEF_PREDICTOR (PRED_POINTER, "pointer", HITRATE (70), 0) |
106 DEF_PREDICTOR (PRED_TREE_POINTER, "pointer (on trees)", HITRATE (70), 0) | 115 DEF_PREDICTOR (PRED_TREE_POINTER, "pointer (on trees)", HITRATE (70), 0) |
107 | 116 |
108 /* NE is probable, EQ not etc... */ | 117 /* NE is probable, EQ not etc... */ |
109 DEF_PREDICTOR (PRED_OPCODE_POSITIVE, "opcode values positive", HITRATE (64), 0) | 118 DEF_PREDICTOR (PRED_OPCODE_POSITIVE, "opcode values positive", HITRATE (59), 0) |
110 DEF_PREDICTOR (PRED_OPCODE_NONEQUAL, "opcode values nonequal", HITRATE (66), 0) | 119 DEF_PREDICTOR (PRED_OPCODE_NONEQUAL, "opcode values nonequal", HITRATE (66), 0) |
111 DEF_PREDICTOR (PRED_FPOPCODE, "fp_opcode", HITRATE (90), 0) | 120 DEF_PREDICTOR (PRED_FPOPCODE, "fp_opcode", HITRATE (90), 0) |
112 DEF_PREDICTOR (PRED_TREE_OPCODE_POSITIVE, "opcode values positive (on trees)", | 121 DEF_PREDICTOR (PRED_TREE_OPCODE_POSITIVE, "opcode values positive (on trees)", |
113 HITRATE (64), 0) | 122 HITRATE (59), 0) |
114 DEF_PREDICTOR (PRED_TREE_OPCODE_NONEQUAL, "opcode values nonequal (on trees)", | 123 DEF_PREDICTOR (PRED_TREE_OPCODE_NONEQUAL, "opcode values nonequal (on trees)", |
115 HITRATE (66), 0) | 124 HITRATE (66), 0) |
116 DEF_PREDICTOR (PRED_TREE_FPOPCODE, "fp_opcode (on trees)", HITRATE (90), 0) | 125 DEF_PREDICTOR (PRED_TREE_FPOPCODE, "fp_opcode (on trees)", HITRATE (90), 0) |
117 | 126 |
118 /* Branch guarding call is probably taken. */ | 127 /* Branch guarding call is probably taken. */ |
119 DEF_PREDICTOR (PRED_CALL, "call", HITRATE (67), 0) | 128 DEF_PREDICTOR (PRED_CALL, "call", HITRATE (67), 0) |
120 | 129 |
121 /* PRED_CALL is not very reliable predictor and it turns out to be even | 130 /* Call predictors are for now ignored, lets leave the predictor |
122 less reliable for indirect calls and polymorphic calls. For spec2k6 | 131 to measure its benefit. */ |
123 the predictio nis slightly in the direction of taking the call. */ | 132 DEF_PREDICTOR (PRED_INDIR_CALL, "indirect call", PROB_EVEN, 0) |
124 DEF_PREDICTOR (PRED_INDIR_CALL, "indirect call", HITRATE (86), 0) | 133 DEF_PREDICTOR (PRED_POLYMORPHIC_CALL, "polymorphic call", PROB_EVEN, 0) |
125 DEF_PREDICTOR (PRED_POLYMORPHIC_CALL, "polymorphic call", HITRATE (59), 0) | 134 DEF_PREDICTOR (PRED_RECURSIVE_CALL, "recursive call", PROB_EVEN, 0) |
126 | |
127 /* Recursive calls are usually not taken or the function will recurse | |
128 indefinitely. */ | |
129 DEF_PREDICTOR (PRED_RECURSIVE_CALL, "recursive call", HITRATE (75), 0) | |
130 | 135 |
131 /* Branch causing function to terminate is probably not taken. */ | 136 /* Branch causing function to terminate is probably not taken. */ |
132 DEF_PREDICTOR (PRED_TREE_EARLY_RETURN, "early return (on trees)", HITRATE (66), | 137 DEF_PREDICTOR (PRED_TREE_EARLY_RETURN, "early return (on trees)", HITRATE (66), |
133 0) | 138 0) |
134 | 139 |
135 /* Branch containing goto is probably not taken. */ | 140 /* Branch containing goto is probably not taken. */ |
136 DEF_PREDICTOR (PRED_GOTO, "goto", HITRATE (66), 0) | 141 DEF_PREDICTOR (PRED_GOTO, "goto", HITRATE (66), 0) |
137 | 142 |
138 /* Branch ending with return constant is probably not taken. */ | 143 /* Branch ending with return constant is probably not taken. */ |
139 DEF_PREDICTOR (PRED_CONST_RETURN, "const return", HITRATE (69), 0) | 144 DEF_PREDICTOR (PRED_CONST_RETURN, "const return", HITRATE (65), 0) |
140 | 145 |
141 /* Branch ending with return negative constant is probably not taken. */ | 146 /* Branch ending with return negative constant is probably not taken. */ |
142 DEF_PREDICTOR (PRED_NEGATIVE_RETURN, "negative return", HITRATE (98), 0) | 147 DEF_PREDICTOR (PRED_NEGATIVE_RETURN, "negative return", HITRATE (98), 0) |
143 | 148 |
144 /* Branch ending with return; is probably not taken */ | 149 /* Branch ending with return; is probably not taken */ |
145 DEF_PREDICTOR (PRED_NULL_RETURN, "null return", HITRATE (91), 0) | 150 DEF_PREDICTOR (PRED_NULL_RETURN, "null return", HITRATE (71), 0) |
146 | 151 |
147 /* Branches to compare induction variable to a loop bound is | 152 /* Branches to compare induction variable to a loop bound is |
148 extremely likely. */ | 153 extremely likely. */ |
149 DEF_PREDICTOR (PRED_LOOP_IV_COMPARE_GUESS, "guess loop iv compare", | 154 DEF_PREDICTOR (PRED_LOOP_IV_COMPARE_GUESS, "guess loop iv compare", |
150 HITRATE (98), 0) | 155 HITRATE (64), 0) |
151 | 156 |
152 /* Use number of loop iterations determined by # of iterations analysis | 157 /* Use number of loop iterations determined by # of iterations analysis |
153 to set probability of branches that compares IV to loop bound variable. */ | 158 to set probability of branches that compares IV to loop bound variable. */ |
154 DEF_PREDICTOR (PRED_LOOP_IV_COMPARE, "loop iv compare", PROB_VERY_LIKELY, | 159 DEF_PREDICTOR (PRED_LOOP_IV_COMPARE, "loop iv compare", PROB_UNINITIALIZED, |
155 PRED_FLAG_FIRST_MATCH) | 160 PRED_FLAG_FIRST_MATCH) |
156 | 161 |
157 /* In the following code | 162 /* In the following code |
158 for (loop1) | 163 for (loop1) |
159 if (cond) | 164 if (cond) |
160 for (loop2) | 165 for (loop2) |
161 body; | 166 body; |
162 guess that cond is unlikely. */ | 167 guess that cond is unlikely. */ |
163 DEF_PREDICTOR (PRED_LOOP_GUARD, "loop guard", HITRATE (66), 0) | 168 DEF_PREDICTOR (PRED_LOOP_GUARD, "loop guard", HITRATE (73), 0) |
164 | 169 |
165 /* Same but for loops containing recursion. */ | 170 /* Same but for loops containing recursion. */ |
166 DEF_PREDICTOR (PRED_LOOP_GUARD_WITH_RECURSION, "loop guard with recursion", | 171 DEF_PREDICTOR (PRED_LOOP_GUARD_WITH_RECURSION, "loop guard with recursion", |
167 HITRATE (85), 0) | 172 HITRATE (85), 0) |
168 | 173 |
170 DEF_PREDICTOR (PRED_HOT_LABEL, "hot label", HITRATE (85), 0) | 175 DEF_PREDICTOR (PRED_HOT_LABEL, "hot label", HITRATE (85), 0) |
171 | 176 |
172 /* Branches to cold labels are extremely unlikely. */ | 177 /* Branches to cold labels are extremely unlikely. */ |
173 DEF_PREDICTOR (PRED_COLD_LABEL, "cold label", PROB_VERY_LIKELY, | 178 DEF_PREDICTOR (PRED_COLD_LABEL, "cold label", PROB_VERY_LIKELY, |
174 PRED_FLAG_FIRST_MATCH) | 179 PRED_FLAG_FIRST_MATCH) |
175 | |
176 | 180 |
177 /* The following predictors are used in Fortran. */ | 181 /* The following predictors are used in Fortran. */ |
178 | 182 |
179 /* Branch leading to an integer overflow are extremely unlikely. */ | 183 /* Branch leading to an integer overflow are extremely unlikely. */ |
180 DEF_PREDICTOR (PRED_FORTRAN_OVERFLOW, "Fortran overflow", PROB_ALWAYS, | 184 DEF_PREDICTOR (PRED_FORTRAN_OVERFLOW, "Fortran overflow", PROB_ALWAYS, |