if (profile_status == PROFILE_ABSENT)
return true;
if (node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
- && freq <= (ENTRY_BLOCK_PTR->frequency * 2 / 3))
+ && freq < (ENTRY_BLOCK_PTR->frequency * 2 / 3))
return false;
if (freq < ENTRY_BLOCK_PTR->frequency / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION))
return false;
return maybe_hot_frequency_p (EDGE_FREQUENCY (e));
}
+
/* Return true in case BB is probably never executed. */
+
bool
probably_never_executed_bb_p (const_basic_block bb)
{
return false;
}
-/* Return true when current function should always be optimized for size. */
+/* Return true if NODE should be optimized for size. */
bool
-optimize_function_for_size_p (struct function *fun)
+cgraph_optimize_for_size_p (struct cgraph_node *node)
{
- struct cgraph_node *node;
-
if (optimize_size)
return true;
- if (!fun || !fun->decl)
- return false;
- node = cgraph_get_node (fun->decl);
if (node && (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED))
return true;
else
return false;
}
+/* Return true when current function should always be optimized for size. */
+
+bool
+optimize_function_for_size_p (struct function *fun)
+{
+ if (optimize_size)
+ return true;
+ if (!fun || !fun->decl)
+ return false;
+ return cgraph_optimize_for_size_p (cgraph_get_node (fun->decl));
+}
+
/* Return true when current function should always be optimized for speed. */
bool
the loop, use it to predict this exit. */
else if (n_exits == 1)
{
- nitercst = estimated_loop_iterations_int (loop, false);
+ nitercst = max_stmt_executions_int (loop, false);
if (nitercst < 0)
continue;
if (nitercst > max)
/* Helper function for expr_expected_value. */
static tree
-expr_expected_value_1 (tree type, tree op0, enum tree_code code, tree op1, bitmap visited)
+expr_expected_value_1 (tree type, tree op0, enum tree_code code,
+ tree op1, bitmap visited)
{
gimple def;
tree decl = gimple_call_fndecl (def);
if (!decl)
return NULL;
- if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
- && DECL_FUNCTION_CODE (decl) == BUILT_IN_EXPECT)
- {
- tree val;
+ if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
+ switch (DECL_FUNCTION_CODE (decl))
+ {
+ case BUILT_IN_EXPECT:
+ {
+ tree val;
+ if (gimple_call_num_args (def) != 2)
+ return NULL;
+ val = gimple_call_arg (def, 0);
+ if (TREE_CONSTANT (val))
+ return val;
+ return gimple_call_arg (def, 1);
+ }
- if (gimple_call_num_args (def) != 2)
- return NULL;
- val = gimple_call_arg (def, 0);
- if (TREE_CONSTANT (val))
- return val;
- return gimple_call_arg (def, 1);
+ case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_N:
+ case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_1:
+ case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_2:
+ case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_4:
+ case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_8:
+ case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_16:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_N:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_1:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_2:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_4:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_8:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_16:
+ /* Assume that any given atomic operation has low contention,
+ and thus the compare-and-swap operation succeeds. */
+ return boolean_true_node;
}
}
static void
predict_paths_for_bb (basic_block cur, basic_block bb,
enum br_predictor pred,
- enum prediction taken)
+ enum prediction taken,
+ bitmap visited)
{
edge e;
edge_iterator ei;
continue;
gcc_assert (bb == cur || dominated_by_p (CDI_POST_DOMINATORS, cur, bb));
- /* See if there is how many edge from e->src that is not abnormal
+ /* See if there is an edge from e->src that is not abnormal
and does not lead to BB. */
FOR_EACH_EDGE (e2, ei2, e->src->succs)
if (e2 != e
/* If there is non-abnormal path leaving e->src, predict edge
using predictor. Otherwise we need to look for paths
- leading to e->src. */
+ leading to e->src.
+
+ The second may lead to infinite loop in the case we are predicitng
+ regions that are only reachable by abnormal edges. We simply
+ prevent visiting given BB twice. */
if (found)
predict_edge_def (e, pred, taken);
- else
- predict_paths_for_bb (e->src, e->src, pred, taken);
+ else if (bitmap_set_bit (visited, e->src->index))
+ predict_paths_for_bb (e->src, e->src, pred, taken, visited);
}
for (son = first_dom_son (CDI_POST_DOMINATORS, cur);
son;
son = next_dom_son (CDI_POST_DOMINATORS, son))
- predict_paths_for_bb (son, bb, pred, taken);
+ predict_paths_for_bb (son, bb, pred, taken, visited);
}
/* Sets branch probabilities according to PREDiction and
predict_paths_leading_to (basic_block bb, enum br_predictor pred,
enum prediction taken)
{
- predict_paths_for_bb (bb, bb, pred, taken);
+ bitmap visited = BITMAP_ALLOC (NULL);
+ predict_paths_for_bb (bb, bb, pred, taken, visited);
+ BITMAP_FREE (visited);
}
/* Like predict_paths_leading_to but take edge instead of basic block. */
break;
}
if (!has_nonloop_edge)
- predict_paths_for_bb (bb, bb, pred, taken);
+ {
+ bitmap visited = BITMAP_ALLOC (NULL);
+ predict_paths_for_bb (bb, bb, pred, taken, visited);
+ BITMAP_FREE (visited);
+ }
else
predict_edge_def (e, pred, taken);
}
build_predict_expr (enum br_predictor predictor, enum prediction taken)
{
tree t = build1 (PREDICT_EXPR, void_type_node,
- build_int_cst (NULL, predictor));
+ build_int_cst (integer_type_node, predictor));
SET_PREDICT_EXPR_OUTCOME (t, taken);
return t;
}
{
{
GIMPLE_PASS,
- "profile", /* name */
+ "profile_estimate", /* name */
gate_estimate_probability, /* gate */
tree_estimate_probability_driver, /* execute */
NULL, /* sub */