aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-prof.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/value-prof.c')
-rw-r--r--gcc/value-prof.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index f1330def688..38ed8b25fdf 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -610,7 +610,7 @@ tree_divmod_fixed_value_transform (tree stmt)
enum tree_code code;
gcov_type val, count, all;
tree modify, op, op1, op2, result, value, tree_val;
- int prob;
+ gcov_type prob;
modify = stmt;
if (TREE_CODE (stmt) == RETURN_EXPR
@@ -651,7 +651,10 @@ tree_divmod_fixed_value_transform (tree stmt)
return false;
/* Compute probability of taking the optimal path. */
- prob = (count * REG_BR_PROB_BASE + all / 2) / all;
+ if (all > 0)
+ prob = (count * REG_BR_PROB_BASE + all / 2) / all;
+ else
+ prob = 0;
tree_val = build_int_cst_wide (get_gcov_type (),
(unsigned HOST_WIDE_INT) val,
@@ -770,7 +773,7 @@ tree_mod_pow2_value_transform (tree stmt)
enum tree_code code;
gcov_type count, wrong_values, all;
tree modify, op, op1, op2, result, value;
- int prob;
+ gcov_type prob;
modify = stmt;
if (TREE_CODE (stmt) == RETURN_EXPR
@@ -817,7 +820,10 @@ tree_mod_pow2_value_transform (tree stmt)
if (check_counter (stmt, "pow2", all, bb_for_stmt (stmt)->count))
return false;
- prob = (count * REG_BR_PROB_BASE + all / 2) / all;
+ if (all > 0)
+ prob = (count * REG_BR_PROB_BASE + all / 2) / all;
+ else
+ prob = 0;
result = tree_mod_pow2 (stmt, op, op1, op2, prob, count, all);
@@ -949,7 +955,7 @@ tree_mod_subtract_transform (tree stmt)
enum tree_code code;
gcov_type count, wrong_values, all;
tree modify, op, op1, op2, result, value;
- int prob1, prob2;
+ gcov_type prob1, prob2;
unsigned int i, steps;
gcov_type count1, count2;
@@ -1016,8 +1022,15 @@ tree_mod_subtract_transform (tree stmt)
}
/* Compute probability of taking the optimal path(s). */
- prob1 = (count1 * REG_BR_PROB_BASE + all / 2) / all;
- prob2 = (count2 * REG_BR_PROB_BASE + all / 2) / all;
+ if (all > 0)
+ {
+ prob1 = (count1 * REG_BR_PROB_BASE + all / 2) / all;
+ prob2 = (count2 * REG_BR_PROB_BASE + all / 2) / all;
+ }
+ else
+ {
+ prob1 = prob2 = 0;
+ }
/* In practice, "steps" is always 2. This interface reflects this,
and will need to be changed if "steps" can change. */
@@ -1174,7 +1187,7 @@ tree_ic_transform (tree stmt)
{
histogram_value histogram;
gcov_type val, count, all;
- int prob;
+ gcov_type prob;
tree call, callee, modify;
struct cgraph_node *direct_call;
@@ -1200,7 +1213,10 @@ tree_ic_transform (tree stmt)
if (4 * count <= 3 * all)
return false;
- prob = (count * REG_BR_PROB_BASE + all / 2) / all;
+ if (all > 0)
+ prob = (count * REG_BR_PROB_BASE + all / 2) / all;
+ else
+ prob = 0;
direct_call = find_func_by_pid ((int)val);
if (direct_call == NULL)
@@ -1365,7 +1381,7 @@ tree_stringops_transform (block_stmt_iterator *bsi)
tree value;
tree dest, src;
unsigned int dest_align, src_align;
- int prob;
+ gcov_type prob;
tree tree_val;
if (!call)
@@ -1399,7 +1415,10 @@ tree_stringops_transform (block_stmt_iterator *bsi)
return false;
if (check_counter (stmt, "value", all, bb_for_stmt (stmt)->count))
return false;
- prob = (count * REG_BR_PROB_BASE + all / 2) / all;
+ if (all > 0)
+ prob = (count * REG_BR_PROB_BASE + all / 2) / all;
+ else
+ prob = 0;
dest = CALL_EXPR_ARG (call, 0);
dest_align = get_pointer_alignment (dest, BIGGEST_ALIGNMENT);
switch (fcode)
@@ -1727,4 +1746,3 @@ value_profile_transformations (void)
return (value_prof_hooks->value_profile_transformations) ();
}
-