value_prob.c (tree_divmod_fixed_value_transform): Use gcov_type.

2008-06-10  Vinodha Ramasamy  <vinodha@google.com>
        * value_prob.c (tree_divmod_fixed_value_transform): Use gcov_type.
	Avoid division by 0.
	(tree_mod_pow2_value_transform): Likewise.
	(tree_ic_transform): Likewise.
	(tree_stringops_transform): Likewise.
	(tree_mod_subtract_transform): Likewise.
	* tree-inline-c (copy_bb): Corrected int type to gcov_type.
	(copy_edges_for_bb): Likewise.
	(initialize_cfun): Likewise.

From-SVN: r136639
This commit is contained in:
Vinodha Ramasamy 2008-06-10 20:21:24 +00:00 committed by Doug Kwan
parent 88b9490b33
commit 0178d64465
3 changed files with 46 additions and 16 deletions

View File

@ -1,3 +1,14 @@
2008-06-10 Vinodha Ramasamy <vinodha@google.com>
* value_prob.c (tree_divmod_fixed_value_transform): Use gcov_type.
Avoid division by 0.
(tree_mod_pow2_value_transform): Likewise.
(tree_ic_transform): Likewise.
(tree_stringops_transform): Likewise.
(tree_mod_subtract_transform): Likewise.
* tree-inline-c (copy_bb): Corrected int type to gcov_type.
(copy_edges_for_bb): Likewise.
(initialize_cfun): Likewise.
2008-06-10 Uros Bizjak <ubizjak@gmail.com> 2008-06-10 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.md (*btdi_rex64): Change operand 1 predicate to * config/i386/i386.md (*btdi_rex64): Change operand 1 predicate to

View File

@ -795,7 +795,8 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data)
later */ later */
static basic_block static basic_block
copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, int count_scale) copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
gcov_type count_scale)
{ {
block_stmt_iterator bsi, copy_bsi; block_stmt_iterator bsi, copy_bsi;
basic_block copy_basic_block; basic_block copy_basic_block;
@ -1108,7 +1109,7 @@ update_ssa_across_abnormal_edges (basic_block bb, basic_block ret_bb,
accordingly. Edges will be taken care of later. Assume aux accordingly. Edges will be taken care of later. Assume aux
pointers to point to the copies of each BB. */ pointers to point to the copies of each BB. */
static void static void
copy_edges_for_bb (basic_block bb, int count_scale, basic_block ret_bb) copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb)
{ {
basic_block new_bb = (basic_block) bb->aux; basic_block new_bb = (basic_block) bb->aux;
edge_iterator ei; edge_iterator ei;
@ -1257,7 +1258,7 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count,
struct function *new_cfun struct function *new_cfun
= (struct function *) ggc_alloc_cleared (sizeof (struct function)); = (struct function *) ggc_alloc_cleared (sizeof (struct function));
struct function *src_cfun = DECL_STRUCT_FUNCTION (callee_fndecl); struct function *src_cfun = DECL_STRUCT_FUNCTION (callee_fndecl);
int count_scale, frequency_scale; gcov_type count_scale, frequency_scale;
if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count) if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count)
count_scale = (REG_BR_PROB_BASE * count count_scale = (REG_BR_PROB_BASE * count
@ -1321,7 +1322,7 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency,
struct function *cfun_to_copy; struct function *cfun_to_copy;
basic_block bb; basic_block bb;
tree new_fndecl = NULL; tree new_fndecl = NULL;
int count_scale, frequency_scale; gcov_type count_scale, frequency_scale;
int last; int last;
if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count) if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count)

View File

@ -610,7 +610,7 @@ tree_divmod_fixed_value_transform (tree stmt)
enum tree_code code; enum tree_code code;
gcov_type val, count, all; gcov_type val, count, all;
tree modify, op, op1, op2, result, value, tree_val; tree modify, op, op1, op2, result, value, tree_val;
int prob; gcov_type prob;
modify = stmt; modify = stmt;
if (TREE_CODE (stmt) == RETURN_EXPR if (TREE_CODE (stmt) == RETURN_EXPR
@ -651,7 +651,10 @@ tree_divmod_fixed_value_transform (tree stmt)
return false; return false;
/* Compute probability of taking the optimal path. */ /* 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 (), tree_val = build_int_cst_wide (get_gcov_type (),
(unsigned HOST_WIDE_INT) val, (unsigned HOST_WIDE_INT) val,
@ -770,7 +773,7 @@ tree_mod_pow2_value_transform (tree stmt)
enum tree_code code; enum tree_code code;
gcov_type count, wrong_values, all; gcov_type count, wrong_values, all;
tree modify, op, op1, op2, result, value; tree modify, op, op1, op2, result, value;
int prob; gcov_type prob;
modify = stmt; modify = stmt;
if (TREE_CODE (stmt) == RETURN_EXPR 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)) if (check_counter (stmt, "pow2", all, bb_for_stmt (stmt)->count))
return false; 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); 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; enum tree_code code;
gcov_type count, wrong_values, all; gcov_type count, wrong_values, all;
tree modify, op, op1, op2, result, value; tree modify, op, op1, op2, result, value;
int prob1, prob2; gcov_type prob1, prob2;
unsigned int i, steps; unsigned int i, steps;
gcov_type count1, count2; gcov_type count1, count2;
@ -1016,8 +1022,15 @@ tree_mod_subtract_transform (tree stmt)
} }
/* Compute probability of taking the optimal path(s). */ /* Compute probability of taking the optimal path(s). */
prob1 = (count1 * REG_BR_PROB_BASE + all / 2) / all; if (all > 0)
prob2 = (count2 * REG_BR_PROB_BASE + all / 2) / all; {
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, /* In practice, "steps" is always 2. This interface reflects this,
and will need to be changed if "steps" can change. */ and will need to be changed if "steps" can change. */
@ -1174,7 +1187,7 @@ tree_ic_transform (tree stmt)
{ {
histogram_value histogram; histogram_value histogram;
gcov_type val, count, all; gcov_type val, count, all;
int prob; gcov_type prob;
tree call, callee, modify; tree call, callee, modify;
struct cgraph_node *direct_call; struct cgraph_node *direct_call;
@ -1200,7 +1213,10 @@ tree_ic_transform (tree stmt)
if (4 * count <= 3 * all) if (4 * count <= 3 * all)
return false; 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); direct_call = find_func_by_pid ((int)val);
if (direct_call == NULL) if (direct_call == NULL)
@ -1365,7 +1381,7 @@ tree_stringops_transform (block_stmt_iterator *bsi)
tree value; tree value;
tree dest, src; tree dest, src;
unsigned int dest_align, src_align; unsigned int dest_align, src_align;
int prob; gcov_type prob;
tree tree_val; tree tree_val;
if (!call) if (!call)
@ -1399,7 +1415,10 @@ tree_stringops_transform (block_stmt_iterator *bsi)
return false; return false;
if (check_counter (stmt, "value", all, bb_for_stmt (stmt)->count)) if (check_counter (stmt, "value", all, bb_for_stmt (stmt)->count))
return false; 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 = CALL_EXPR_ARG (call, 0);
dest_align = get_pointer_alignment (dest, BIGGEST_ALIGNMENT); dest_align = get_pointer_alignment (dest, BIGGEST_ALIGNMENT);
switch (fcode) switch (fcode)
@ -1727,4 +1746,3 @@ value_profile_transformations (void)
return (value_prof_hooks->value_profile_transformations) (); return (value_prof_hooks->value_profile_transformations) ();
} }