summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authortejohnson <tejohnson@138bc75d-0d04-0410-961f-82ee72b054a4>2013-10-18 17:25:44 +0000
committertejohnson <tejohnson@138bc75d-0d04-0410-961f-82ee72b054a4>2013-10-18 17:25:44 +0000
commitc1acf60c9540fffb6d89b1c39bb577e5fd9eb529 (patch)
tree4eafca465dab7b2da07686cc73ac95aea2125ec5 /gcc
parentf2f653da531b4042f9dcc183ae94cee4469fbf3e (diff)
downloadgcc-c1acf60c9540fffb6d89b1c39bb577e5fd9eb529.tar.gz
2013-10-18 Teresa Johnson <tejohnson@google.com>
* predict.c (probably_never_executed): Compare frequency-based count to number of training runs. * params.def (UNLIKELY_BB_COUNT_FRACTION): New parameter. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203830 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/params.def5
-rw-r--r--gcc/predict.c26
3 files changed, 32 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4249ae29fe7..43ae7172579 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2013-10-18 Teresa Johnson <tejohnson@google.com>
+
+ * predict.c (probably_never_executed): Compare frequency-based
+ count to number of training runs.
+ * params.def (UNLIKELY_BB_COUNT_FRACTION): New parameter.
+
2013-10-18 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* config/arm/arm.c (cortexa9_extra_costs): New table.
diff --git a/gcc/params.def b/gcc/params.def
index def5a9a5eaa..c0f962256f1 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -373,6 +373,11 @@ DEFPARAM(HOT_BB_FREQUENCY_FRACTION,
"Select fraction of the maximal frequency of executions of basic block in function given basic block needs to have to be considered hot",
1000, 0, 0)
+DEFPARAM(UNLIKELY_BB_COUNT_FRACTION,
+ "unlikely-bb-count-fraction",
+ "The minimum fraction of profile runs a given basic block execution count must be not to be considered unlikely",
+ 20, 1, 10000)
+
DEFPARAM (PARAM_ALIGN_THRESHOLD,
"align-threshold",
"Select fraction of the maximal frequency of executions of basic block in function given basic block get alignment",
diff --git a/gcc/predict.c b/gcc/predict.c
index ca1a0c9802c..2f1cb89c4ab 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -237,17 +237,33 @@ probably_never_executed (struct function *fun,
gcc_checking_assert (fun);
if (profile_status_for_function (fun) == PROFILE_READ)
{
- if ((count * 4 + profile_info->runs / 2) / profile_info->runs > 0)
+ int unlikely_count_fraction = PARAM_VALUE (UNLIKELY_BB_COUNT_FRACTION);
+ if (count * unlikely_count_fraction >= profile_info->runs)
return false;
if (!frequency)
return true;
if (!ENTRY_BLOCK_PTR->frequency)
return false;
- if (ENTRY_BLOCK_PTR->count && ENTRY_BLOCK_PTR->count < REG_BR_PROB_BASE)
+ if (ENTRY_BLOCK_PTR->count)
{
- return (RDIV (frequency * ENTRY_BLOCK_PTR->count,
- ENTRY_BLOCK_PTR->frequency)
- < REG_BR_PROB_BASE / 4);
+ gcov_type computed_count;
+ /* Check for possibility of overflow, in which case entry bb count
+ is large enough to do the division first without losing much
+ precision. */
+ if (ENTRY_BLOCK_PTR->count < REG_BR_PROB_BASE * REG_BR_PROB_BASE)
+ {
+ gcov_type scaled_count
+ = frequency * ENTRY_BLOCK_PTR->count * unlikely_count_fraction;
+ computed_count = RDIV (scaled_count, ENTRY_BLOCK_PTR->frequency);
+ }
+ else
+ {
+ computed_count = RDIV (ENTRY_BLOCK_PTR->count,
+ ENTRY_BLOCK_PTR->frequency);
+ computed_count *= frequency * unlikely_count_fraction;
+ }
+ if (computed_count >= profile_info->runs)
+ return false;
}
return true;
}