aboutsummaryrefslogtreecommitdiff
path: root/gcc/cfgcleanup.c
diff options
context:
space:
mode:
authorEdward Smith-Rowland <3dw4rd@verizon.net>2017-07-20 14:54:44 +0000
committerEdward Smith-Rowland <3dw4rd@verizon.net>2017-07-20 14:54:44 +0000
commit3acaf2e51caf356a9afc763cfd70b91d1ab094b5 (patch)
treef13b1087143457ae5c053b6ec3b664c2aaeab169 /gcc/cfgcleanup.c
parentc4d46197c5fe4461da59ce027bc68306c43186b0 (diff)
Merged revisions r232323 through r250392 to the branch
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/tr29124@250393 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfgcleanup.c')
-rw-r--r--gcc/cfgcleanup.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index d55b0ceb832..5d00fafffa3 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -558,8 +558,8 @@ try_forward_edges (int mode, basic_block b)
else
{
/* Save the values now, as the edge may get removed. */
- gcov_type edge_count = e->count;
- int edge_probability = e->probability;
+ profile_count edge_count = e->count;
+ profile_probability edge_probability = e->probability;
int edge_frequency;
int n = 0;
@@ -585,7 +585,7 @@ try_forward_edges (int mode, basic_block b)
/* We successfully forwarded the edge. Now update profile
data: for each edge we traversed in the chain, remove
the original edge's execution count. */
- edge_frequency = apply_probability (b->frequency, edge_probability);
+ edge_frequency = edge_probability.apply (b->frequency);
do
{
@@ -603,8 +603,6 @@ try_forward_edges (int mode, basic_block b)
else
{
first->count -= edge_count;
- if (first->count < 0)
- first->count = 0;
first->frequency -= edge_frequency;
if (first->frequency < 0)
first->frequency = 0;
@@ -619,8 +617,6 @@ try_forward_edges (int mode, basic_block b)
}
t->count -= edge_count;
- if (t->count < 0)
- t->count = 0;
first = t->dest;
}
while (first != target);
@@ -1714,24 +1710,28 @@ outgoing_edges_match (int mode, basic_block bb1, basic_block bb2)
&& optimize_bb_for_speed_p (bb1)
&& optimize_bb_for_speed_p (bb2))
{
- int prob2;
+ profile_probability prob2;
if (b1->dest == b2->dest)
prob2 = b2->probability;
else
/* Do not use f2 probability as f2 may be forwarded. */
- prob2 = REG_BR_PROB_BASE - b2->probability;
+ prob2 = b2->probability.invert ();
/* Fail if the difference in probabilities is greater than 50%.
This rules out two well-predicted branches with opposite
outcomes. */
- if (abs (b1->probability - prob2) > REG_BR_PROB_BASE / 2)
+ if (b1->probability.differs_lot_from_p (prob2))
{
if (dump_file)
- fprintf (dump_file,
- "Outcomes of branch in bb %i and %i differ too much (%i %i)\n",
- bb1->index, bb2->index, b1->probability, prob2);
-
+ {
+ fprintf (dump_file,
+ "Outcomes of branch in bb %i and %i differ too"
+ " much (", bb1->index, bb2->index);
+ b1->probability.dump (dump_file);
+ prob2.dump (dump_file);
+ fprintf (dump_file, ")\n");
+ }
return false;
}
}
@@ -2017,6 +2017,11 @@ try_crossjump_to_edge (int mode, edge e1, edge e2,
if (newpos2 != NULL_RTX)
src2 = BLOCK_FOR_INSN (newpos2);
+ /* Check that SRC1 and SRC2 have preds again. They may have changed
+ above due to the call to flow_find_cross_jump. */
+ if (EDGE_COUNT (src1->preds) == 0 || EDGE_COUNT (src2->preds) == 0)
+ return false;
+
if (dir == dir_backward)
{
#define SWAP(T, X, Y) do { T tmp = (X); (X) = (Y); (Y) = tmp; } while (0)
@@ -2141,23 +2146,16 @@ try_crossjump_to_edge (int mode, edge e1, edge e2,
if (FORWARDER_BLOCK_P (s2->dest))
{
single_succ_edge (s2->dest)->count -= s2->count;
- if (single_succ_edge (s2->dest)->count < 0)
- single_succ_edge (s2->dest)->count = 0;
s2->dest->count -= s2->count;
s2->dest->frequency -= EDGE_FREQUENCY (s);
if (s2->dest->frequency < 0)
s2->dest->frequency = 0;
- if (s2->dest->count < 0)
- s2->dest->count = 0;
}
if (!redirect_edges_to->frequency && !src1->frequency)
- s->probability = (s->probability + s2->probability) / 2;
- else
- s->probability
- = ((s->probability * redirect_edges_to->frequency +
- s2->probability * src1->frequency)
- / (redirect_edges_to->frequency + src1->frequency));
+ s->probability = s->probability.combine_with_freq
+ (redirect_edges_to->frequency,
+ s2->probability, src1->frequency);
}
/* Adjust count and frequency for the block. An earlier jump
@@ -2661,7 +2659,7 @@ trivially_empty_bb_p (basic_block bb)
/* Return true if BB contains just a return and possibly a USE of the
return value. Fill in *RET and *USE with the return and use insns
- if any found, otherwise NULL. */
+ if any found, otherwise NULL. All CLOBBERs are ignored. */
static bool
bb_is_just_return (basic_block bb, rtx_insn **ret, rtx_insn **use)
@@ -2675,13 +2673,15 @@ bb_is_just_return (basic_block bb, rtx_insn **ret, rtx_insn **use)
FOR_BB_INSNS (bb, insn)
if (NONDEBUG_INSN_P (insn))
{
- if (!*ret && ANY_RETURN_P (PATTERN (insn)))
+ rtx pat = PATTERN (insn);
+
+ if (!*ret && ANY_RETURN_P (pat))
*ret = insn;
- else if (!*ret && !*use && GET_CODE (PATTERN (insn)) == USE
- && REG_P (XEXP (PATTERN (insn), 0))
- && REG_FUNCTION_VALUE_P (XEXP (PATTERN (insn), 0)))
+ else if (!*ret && !*use && GET_CODE (pat) == USE
+ && REG_P (XEXP (pat, 0))
+ && REG_FUNCTION_VALUE_P (XEXP (pat, 0)))
*use = insn;
- else
+ else if (GET_CODE (pat) != CLOBBER)
return false;
}