aboutsummaryrefslogtreecommitdiff
path: root/gcc/predict.c
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2013-10-03 05:06:05 +0000
committerTeresa Johnson <tejohnson@gcc.gnu.org>2013-10-03 05:06:05 +0000
commit79221839a3c9c0e8a4cf5ea130bcf24062ee3995 (patch)
treed85c8dce4505e035ecaa38597a50dd80df80808e /gcc/predict.c
parent697786593677771f060fdb99dc1114d7bb48f372 (diff)
downloadgcc-79221839a3c9c0e8a4cf5ea130bcf24062ee3995.zip
gcc-79221839a3c9c0e8a4cf5ea130bcf24062ee3995.tar.gz
gcc-79221839a3c9c0e8a4cf5ea130bcf24062ee3995.tar.bz2
predict.c (probably_never_executed): New function.
2013-10-02 Teresa Johnson <tejohnson@google.com> * predict.c (probably_never_executed): New function. (probably_never_executed_bb_p): Invoke probably_never_executed. (probably_never_executed_edge_p): Ditto. * bb-reorder.c (find_rarely_executed_basic_blocks_and_crossing_edges): Treat profile insanities conservatively. From-SVN: r203152
Diffstat (limited to 'gcc/predict.c')
-rw-r--r--gcc/predict.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/gcc/predict.c b/gcc/predict.c
index 4815e75..2909117 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -226,23 +226,26 @@ maybe_hot_edge_p (edge e)
}
-/* Return true in case BB is probably never executed. */
-bool
-probably_never_executed_bb_p (struct function *fun, const_basic_block bb)
+/* Return true if profile COUNT and FREQUENCY, or function FUN static
+ node frequency reflects never being executed. */
+
+static bool
+probably_never_executed (struct function *fun,
+ gcov_type count, int frequency)
{
gcc_checking_assert (fun);
if (profile_status_for_function (fun) == PROFILE_READ)
{
- if ((bb->count * 4 + profile_info->runs / 2) / profile_info->runs > 0)
+ if ((count * 4 + profile_info->runs / 2) / profile_info->runs > 0)
return false;
- if (!bb->frequency)
+ if (!frequency)
return true;
if (!ENTRY_BLOCK_PTR->frequency)
return false;
if (ENTRY_BLOCK_PTR->count && ENTRY_BLOCK_PTR->count < REG_BR_PROB_BASE)
{
- return (RDIV (bb->frequency * ENTRY_BLOCK_PTR->count,
+ return (RDIV (frequency * ENTRY_BLOCK_PTR->count,
ENTRY_BLOCK_PTR->frequency)
< REG_BR_PROB_BASE / 4);
}
@@ -256,19 +259,21 @@ probably_never_executed_bb_p (struct function *fun, const_basic_block bb)
}
+/* Return true in case BB is probably never executed. */
+
+bool
+probably_never_executed_bb_p (struct function *fun, const_basic_block bb)
+{
+ return probably_never_executed (fun, bb->count, bb->frequency);
+}
+
+
/* Return true in case edge E is probably never executed. */
bool
probably_never_executed_edge_p (struct function *fun, edge e)
{
- gcc_checking_assert (fun);
- if (profile_info && flag_branch_probabilities)
- return ((e->count + profile_info->runs / 2) / profile_info->runs) == 0;
- if ((!profile_info || !flag_branch_probabilities)
- && (cgraph_get_node (fun->decl)->frequency
- == NODE_FREQUENCY_UNLIKELY_EXECUTED))
- return true;
- return false;
+ return probably_never_executed (fun, e->count, EDGE_FREQUENCY (e));
}
/* Return true if NODE should be optimized for size. */