Commit 5e48d8a0 by Martin Liska Committed by Martin Liska

Replace spaces with tabs and remove trailing whitespaces

	* tree-ssa-uninit.c: Fix whitespaces in the source file.
	The change is just automatical.

From-SVN: r230998
parent 2f0fc505
2015-11-27 Martin Liska <mliska@suse.cz> 2015-11-27 Martin Liska <mliska@suse.cz>
* tree-ssa-uninit.c: Fix whitespaces in the source file.
The change is just automatical.
2015-11-27 Martin Liska <mliska@suse.cz>
* tree-chkp.c (chkp_make_static_bounds): Release buffer * tree-chkp.c (chkp_make_static_bounds): Release buffer
used for string. used for string.
...@@ -76,8 +76,8 @@ static bool ...@@ -76,8 +76,8 @@ static bool
has_undefined_value_p (tree t) has_undefined_value_p (tree t)
{ {
return (ssa_undefined_value_p (t) return (ssa_undefined_value_p (t)
|| (possibly_undefined_names || (possibly_undefined_names
&& possibly_undefined_names->contains (t))); && possibly_undefined_names->contains (t)));
} }
...@@ -270,9 +270,9 @@ can_skip_redundant_opnd (tree opnd, gimple *phi) ...@@ -270,9 +270,9 @@ can_skip_redundant_opnd (tree opnd, gimple *phi)
{ {
tree op = gimple_phi_arg_def (op_def, i); tree op = gimple_phi_arg_def (op_def, i);
if (TREE_CODE (op) != SSA_NAME) if (TREE_CODE (op) != SSA_NAME)
continue; continue;
if (op != phi_def && uninit_undefined_value_p (op)) if (op != phi_def && uninit_undefined_value_p (op))
return false; return false;
} }
return true; return true;
...@@ -296,10 +296,10 @@ compute_uninit_opnds_pos (gphi *phi) ...@@ -296,10 +296,10 @@ compute_uninit_opnds_pos (gphi *phi)
{ {
tree op = gimple_phi_arg_def (phi, i); tree op = gimple_phi_arg_def (phi, i);
if (TREE_CODE (op) == SSA_NAME if (TREE_CODE (op) == SSA_NAME
&& uninit_undefined_value_p (op) && uninit_undefined_value_p (op)
&& !can_skip_redundant_opnd (op, phi)) && !can_skip_redundant_opnd (op, phi))
{ {
if (cfun->has_nonlocal_label || cfun->calls_setjmp) if (cfun->has_nonlocal_label || cfun->calls_setjmp)
{ {
/* Ignore SSA_NAMEs that appear on abnormal edges /* Ignore SSA_NAMEs that appear on abnormal edges
somewhere. */ somewhere. */
...@@ -323,7 +323,7 @@ find_pdom (basic_block block) ...@@ -323,7 +323,7 @@ find_pdom (basic_block block)
else else
{ {
basic_block bb basic_block bb
= get_immediate_dominator (CDI_POST_DOMINATORS, block); = get_immediate_dominator (CDI_POST_DOMINATORS, block);
if (! bb) if (! bb)
return EXIT_BLOCK_PTR_FOR_FN (cfun); return EXIT_BLOCK_PTR_FOR_FN (cfun);
return bb; return bb;
...@@ -398,8 +398,8 @@ find_control_equiv_block (basic_block bb) ...@@ -398,8 +398,8 @@ find_control_equiv_block (basic_block bb)
static bool static bool
compute_control_dep_chain (basic_block bb, basic_block dep_bb, compute_control_dep_chain (basic_block bb, basic_block dep_bb,
vec<edge> *cd_chains, vec<edge> *cd_chains,
size_t *num_chains, size_t *num_chains,
vec<edge> *cur_cd_chain, vec<edge> *cur_cd_chain,
int *num_calls) int *num_calls)
{ {
...@@ -426,7 +426,7 @@ compute_control_dep_chain (basic_block bb, basic_block dep_bb, ...@@ -426,7 +426,7 @@ compute_control_dep_chain (basic_block bb, basic_block dep_bb,
edge e = (*cur_cd_chain)[i]; edge e = (*cur_cd_chain)[i];
/* Cycle detected. */ /* Cycle detected. */
if (e->src == bb) if (e->src == bb)
return false; return false;
} }
FOR_EACH_EDGE (e, ei, bb->succs) FOR_EACH_EDGE (e, ei, bb->succs)
...@@ -434,39 +434,39 @@ compute_control_dep_chain (basic_block bb, basic_block dep_bb, ...@@ -434,39 +434,39 @@ compute_control_dep_chain (basic_block bb, basic_block dep_bb,
basic_block cd_bb; basic_block cd_bb;
int post_dom_check = 0; int post_dom_check = 0;
if (e->flags & (EDGE_FAKE | EDGE_ABNORMAL)) if (e->flags & (EDGE_FAKE | EDGE_ABNORMAL))
continue; continue;
cd_bb = e->dest; cd_bb = e->dest;
cur_cd_chain->safe_push (e); cur_cd_chain->safe_push (e);
while (!is_non_loop_exit_postdominating (cd_bb, bb)) while (!is_non_loop_exit_postdominating (cd_bb, bb))
{ {
if (cd_bb == dep_bb) if (cd_bb == dep_bb)
{ {
/* Found a direct control dependence. */ /* Found a direct control dependence. */
if (*num_chains < MAX_NUM_CHAINS) if (*num_chains < MAX_NUM_CHAINS)
{ {
cd_chains[*num_chains] = cur_cd_chain->copy (); cd_chains[*num_chains] = cur_cd_chain->copy ();
(*num_chains)++; (*num_chains)++;
} }
found_cd_chain = true; found_cd_chain = true;
/* Check path from next edge. */ /* Check path from next edge. */
break; break;
} }
/* Now check if DEP_BB is indirectly control dependent on BB. */ /* Now check if DEP_BB is indirectly control dependent on BB. */
if (compute_control_dep_chain (cd_bb, dep_bb, cd_chains, if (compute_control_dep_chain (cd_bb, dep_bb, cd_chains,
num_chains, cur_cd_chain, num_calls)) num_chains, cur_cd_chain, num_calls))
{ {
found_cd_chain = true; found_cd_chain = true;
break; break;
} }
cd_bb = find_pdom (cd_bb); cd_bb = find_pdom (cd_bb);
post_dom_check++; post_dom_check++;
if (cd_bb == EXIT_BLOCK_PTR_FOR_FN (cfun) || post_dom_check > if (cd_bb == EXIT_BLOCK_PTR_FOR_FN (cfun) || post_dom_check >
MAX_POSTDOM_CHECK) MAX_POSTDOM_CHECK)
break; break;
} }
cur_cd_chain->pop (); cur_cd_chain->pop ();
gcc_assert (cur_cd_chain->length () == cur_chain_len); gcc_assert (cur_cd_chain->length () == cur_chain_len);
} }
...@@ -508,8 +508,8 @@ typedef vec<pred_chain, va_heap, vl_ptr> pred_chain_union; ...@@ -508,8 +508,8 @@ typedef vec<pred_chain, va_heap, vl_ptr> pred_chain_union;
static bool static bool
convert_control_dep_chain_into_preds (vec<edge> *dep_chains, convert_control_dep_chain_into_preds (vec<edge> *dep_chains,
size_t num_chains, size_t num_chains,
pred_chain_union *preds) pred_chain_union *preds)
{ {
bool has_valid_pred = false; bool has_valid_pred = false;
size_t i, j; size_t i, j;
...@@ -527,48 +527,48 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains, ...@@ -527,48 +527,48 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains,
has_valid_pred = false; has_valid_pred = false;
pred_chain t_chain = vNULL; pred_chain t_chain = vNULL;
for (j = 0; j < one_cd_chain.length (); j++) for (j = 0; j < one_cd_chain.length (); j++)
{ {
gimple *cond_stmt; gimple *cond_stmt;
gimple_stmt_iterator gsi; gimple_stmt_iterator gsi;
basic_block guard_bb; basic_block guard_bb;
pred_info one_pred; pred_info one_pred;
edge e; edge e;
e = one_cd_chain[j]; e = one_cd_chain[j];
guard_bb = e->src; guard_bb = e->src;
gsi = gsi_last_bb (guard_bb); gsi = gsi_last_bb (guard_bb);
if (gsi_end_p (gsi)) if (gsi_end_p (gsi))
{ {
has_valid_pred = false; has_valid_pred = false;
break; break;
} }
cond_stmt = gsi_stmt (gsi); cond_stmt = gsi_stmt (gsi);
if (is_gimple_call (cond_stmt) if (is_gimple_call (cond_stmt)
&& EDGE_COUNT (e->src->succs) >= 2) && EDGE_COUNT (e->src->succs) >= 2)
{ {
/* Ignore EH edge. Can add assertion /* Ignore EH edge. Can add assertion
on the other edge's flag. */ on the other edge's flag. */
continue; continue;
} }
/* Skip if there is essentially one succesor. */ /* Skip if there is essentially one succesor. */
if (EDGE_COUNT (e->src->succs) == 2) if (EDGE_COUNT (e->src->succs) == 2)
{ {
edge e1; edge e1;
edge_iterator ei1; edge_iterator ei1;
bool skip = false; bool skip = false;
FOR_EACH_EDGE (e1, ei1, e->src->succs) FOR_EACH_EDGE (e1, ei1, e->src->succs)
{ {
if (EDGE_COUNT (e1->dest->succs) == 0) if (EDGE_COUNT (e1->dest->succs) == 0)
{ {
skip = true; skip = true;
break; break;
} }
} }
if (skip) if (skip)
continue; continue;
} }
if (gimple_code (cond_stmt) == GIMPLE_COND) if (gimple_code (cond_stmt) == GIMPLE_COND)
{ {
one_pred.pred_lhs = gimple_cond_lhs (cond_stmt); one_pred.pred_lhs = gimple_cond_lhs (cond_stmt);
one_pred.pred_rhs = gimple_cond_rhs (cond_stmt); one_pred.pred_rhs = gimple_cond_rhs (cond_stmt);
...@@ -603,7 +603,7 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains, ...@@ -603,7 +603,7 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains,
} }
} }
/* If more than one label reaches this block or the case /* If more than one label reaches this block or the case
label doesn't have a single value (like the default one) label doesn't have a single value (like the default one)
fail. */ fail. */
if (!l if (!l
|| !CASE_LOW (l) || !CASE_LOW (l)
...@@ -621,11 +621,11 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains, ...@@ -621,11 +621,11 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains,
has_valid_pred = true; has_valid_pred = true;
} }
else else
{ {
has_valid_pred = false; has_valid_pred = false;
break; break;
} }
} }
if (!has_valid_pred) if (!has_valid_pred)
break; break;
...@@ -642,8 +642,8 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains, ...@@ -642,8 +642,8 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains,
static bool static bool
find_predicates (pred_chain_union *preds, find_predicates (pred_chain_union *preds,
basic_block phi_bb, basic_block phi_bb,
basic_block use_bb) basic_block use_bb)
{ {
size_t num_chains = 0, i; size_t num_chains = 0, i;
int num_calls = 0; int num_calls = 0;
...@@ -659,9 +659,9 @@ find_predicates (pred_chain_union *preds, ...@@ -659,9 +659,9 @@ find_predicates (pred_chain_union *preds,
{ {
basic_block ctrl_eq_bb = find_control_equiv_block (cd_root); basic_block ctrl_eq_bb = find_control_equiv_block (cd_root);
if (ctrl_eq_bb && dominated_by_p (CDI_DOMINATORS, use_bb, ctrl_eq_bb)) if (ctrl_eq_bb && dominated_by_p (CDI_DOMINATORS, use_bb, ctrl_eq_bb))
cd_root = ctrl_eq_bb; cd_root = ctrl_eq_bb;
else else
break; break;
} }
compute_control_dep_chain (cd_root, use_bb, dep_chains, &num_chains, compute_control_dep_chain (cd_root, use_bb, dep_chains, &num_chains,
...@@ -699,33 +699,33 @@ collect_phi_def_edges (gphi *phi, basic_block cd_root, ...@@ -699,33 +699,33 @@ collect_phi_def_edges (gphi *phi, basic_block cd_root,
opnd = gimple_phi_arg_def (phi, i); opnd = gimple_phi_arg_def (phi, i);
if (TREE_CODE (opnd) != SSA_NAME) if (TREE_CODE (opnd) != SSA_NAME)
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
fprintf (dump_file, "\n[CHECK] Found def edge %d in ", (int)i); fprintf (dump_file, "\n[CHECK] Found def edge %d in ", (int)i);
print_gimple_stmt (dump_file, phi, 0, 0); print_gimple_stmt (dump_file, phi, 0, 0);
} }
edges->safe_push (opnd_edge); edges->safe_push (opnd_edge);
} }
else else
{ {
gimple *def = SSA_NAME_DEF_STMT (opnd); gimple *def = SSA_NAME_DEF_STMT (opnd);
if (gimple_code (def) == GIMPLE_PHI if (gimple_code (def) == GIMPLE_PHI
&& dominated_by_p (CDI_DOMINATORS, && dominated_by_p (CDI_DOMINATORS,
gimple_bb (def), cd_root)) gimple_bb (def), cd_root))
collect_phi_def_edges (as_a <gphi *> (def), cd_root, edges, collect_phi_def_edges (as_a <gphi *> (def), cd_root, edges,
visited_phis); visited_phis);
else if (!uninit_undefined_value_p (opnd)) else if (!uninit_undefined_value_p (opnd))
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
fprintf (dump_file, "\n[CHECK] Found def edge %d in ", (int)i); fprintf (dump_file, "\n[CHECK] Found def edge %d in ", (int)i);
print_gimple_stmt (dump_file, phi, 0, 0); print_gimple_stmt (dump_file, phi, 0, 0);
} }
edges->safe_push (opnd_edge); edges->safe_push (opnd_edge);
} }
} }
} }
} }
...@@ -769,14 +769,14 @@ find_def_preds (pred_chain_union *preds, gphi *phi) ...@@ -769,14 +769,14 @@ find_def_preds (pred_chain_union *preds, gphi *phi)
&num_chains, &cur_chain, &num_calls); &num_chains, &cur_chain, &num_calls);
/* Now update the newly added chains with /* Now update the newly added chains with
the phi operand edge: */ the phi operand edge: */
if (EDGE_COUNT (opnd_edge->src->succs) > 1) if (EDGE_COUNT (opnd_edge->src->succs) > 1)
{ {
if (prev_nc == num_chains && num_chains < MAX_NUM_CHAINS) if (prev_nc == num_chains && num_chains < MAX_NUM_CHAINS)
dep_chains[num_chains++] = vNULL; dep_chains[num_chains++] = vNULL;
for (j = prev_nc; j < num_chains; j++) for (j = prev_nc; j < num_chains; j++)
dep_chains[j].safe_push (opnd_edge); dep_chains[j].safe_push (opnd_edge);
} }
} }
has_valid_pred has_valid_pred
...@@ -790,7 +790,7 @@ find_def_preds (pred_chain_union *preds, gphi *phi) ...@@ -790,7 +790,7 @@ find_def_preds (pred_chain_union *preds, gphi *phi)
static void static void
dump_predicates (gimple *usestmt, pred_chain_union preds, dump_predicates (gimple *usestmt, pred_chain_union preds,
const char* msg) const char* msg)
{ {
size_t i, j; size_t i, j;
pred_chain one_pred_chain = vNULL; pred_chain one_pred_chain = vNULL;
...@@ -807,22 +807,22 @@ dump_predicates (gimple *usestmt, pred_chain_union preds, ...@@ -807,22 +807,22 @@ dump_predicates (gimple *usestmt, pred_chain_union preds,
np = one_pred_chain.length (); np = one_pred_chain.length ();
for (j = 0; j < np; j++) for (j = 0; j < np; j++)
{ {
pred_info one_pred = one_pred_chain[j]; pred_info one_pred = one_pred_chain[j];
if (one_pred.invert) if (one_pred.invert)
fprintf (dump_file, " (.NOT.) "); fprintf (dump_file, " (.NOT.) ");
print_generic_expr (dump_file, one_pred.pred_lhs, 0); print_generic_expr (dump_file, one_pred.pred_lhs, 0);
fprintf (dump_file, " %s ", op_symbol_code (one_pred.cond_code)); fprintf (dump_file, " %s ", op_symbol_code (one_pred.cond_code));
print_generic_expr (dump_file, one_pred.pred_rhs, 0); print_generic_expr (dump_file, one_pred.pred_rhs, 0);
if (j < np - 1) if (j < np - 1)
fprintf (dump_file, " (.AND.) "); fprintf (dump_file, " (.AND.) ");
else else
fprintf (dump_file, "\n"); fprintf (dump_file, "\n");
} }
if (i < num_preds - 1) if (i < num_preds - 1)
fprintf (dump_file, "(.OR.)\n"); fprintf (dump_file, "(.OR.)\n");
else else
fprintf (dump_file, "\n\n"); fprintf (dump_file, "\n\n");
} }
} }
...@@ -845,7 +845,7 @@ destroy_predicate_vecs (pred_chain_union *preds) ...@@ -845,7 +845,7 @@ destroy_predicate_vecs (pred_chain_union *preds)
static enum tree_code static enum tree_code
get_cmp_code (enum tree_code orig_cmp_code, get_cmp_code (enum tree_code orig_cmp_code,
bool swap_cond, bool invert) bool swap_cond, bool invert)
{ {
enum tree_code tc = orig_cmp_code; enum tree_code tc = orig_cmp_code;
...@@ -896,27 +896,27 @@ is_value_included_in (tree val, tree boundary, enum tree_code cmpc) ...@@ -896,27 +896,27 @@ is_value_included_in (tree val, tree boundary, enum tree_code cmpc)
if (is_unsigned) if (is_unsigned)
{ {
if (cmpc == EQ_EXPR) if (cmpc == EQ_EXPR)
result = tree_int_cst_equal (val, boundary); result = tree_int_cst_equal (val, boundary);
else if (cmpc == LT_EXPR) else if (cmpc == LT_EXPR)
result = tree_int_cst_lt (val, boundary); result = tree_int_cst_lt (val, boundary);
else else
{ {
gcc_assert (cmpc == LE_EXPR); gcc_assert (cmpc == LE_EXPR);
result = tree_int_cst_le (val, boundary); result = tree_int_cst_le (val, boundary);
} }
} }
else else
{ {
if (cmpc == EQ_EXPR) if (cmpc == EQ_EXPR)
result = tree_int_cst_equal (val, boundary); result = tree_int_cst_equal (val, boundary);
else if (cmpc == LT_EXPR) else if (cmpc == LT_EXPR)
result = tree_int_cst_lt (val, boundary); result = tree_int_cst_lt (val, boundary);
else else
{ {
gcc_assert (cmpc == LE_EXPR); gcc_assert (cmpc == LE_EXPR);
result = (tree_int_cst_equal (val, boundary) result = (tree_int_cst_equal (val, boundary)
|| tree_int_cst_lt (val, boundary)); || tree_int_cst_lt (val, boundary));
} }
} }
if (inverted) if (inverted)
...@@ -931,8 +931,8 @@ is_value_included_in (tree val, tree boundary, enum tree_code cmpc) ...@@ -931,8 +931,8 @@ is_value_included_in (tree val, tree boundary, enum tree_code cmpc)
static bool static bool
find_matching_predicate_in_rest_chains (pred_info pred, find_matching_predicate_in_rest_chains (pred_info pred,
pred_chain_union preds, pred_chain_union preds,
size_t num_pred_chains) size_t num_pred_chains)
{ {
size_t i, j, n; size_t i, j, n;
...@@ -946,24 +946,24 @@ find_matching_predicate_in_rest_chains (pred_info pred, ...@@ -946,24 +946,24 @@ find_matching_predicate_in_rest_chains (pred_info pred,
pred_chain one_chain = preds[i]; pred_chain one_chain = preds[i];
n = one_chain.length (); n = one_chain.length ();
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
{ {
pred_info pred2 = one_chain[j]; pred_info pred2 = one_chain[j];
/* Can relax the condition comparison to not /* Can relax the condition comparison to not
use address comparison. However, the most common use address comparison. However, the most common
case is that multiple control dependent paths share case is that multiple control dependent paths share
a common path prefix, so address comparison should a common path prefix, so address comparison should
be ok. */ be ok. */
if (operand_equal_p (pred2.pred_lhs, pred.pred_lhs, 0) if (operand_equal_p (pred2.pred_lhs, pred.pred_lhs, 0)
&& operand_equal_p (pred2.pred_rhs, pred.pred_rhs, 0) && operand_equal_p (pred2.pred_rhs, pred.pred_rhs, 0)
&& pred2.invert == pred.invert) && pred2.invert == pred.invert)
{ {
found = true; found = true;
break; break;
} }
} }
if (!found) if (!found)
return false; return false;
} }
return true; return true;
} }
...@@ -971,11 +971,11 @@ find_matching_predicate_in_rest_chains (pred_info pred, ...@@ -971,11 +971,11 @@ find_matching_predicate_in_rest_chains (pred_info pred,
/* Forward declaration. */ /* Forward declaration. */
static bool static bool
is_use_properly_guarded (gimple *use_stmt, is_use_properly_guarded (gimple *use_stmt,
basic_block use_bb, basic_block use_bb,
gphi *phi, gphi *phi,
unsigned uninit_opnds, unsigned uninit_opnds,
pred_chain_union *def_preds, pred_chain_union *def_preds,
hash_set<gphi *> *visited_phis); hash_set<gphi *> *visited_phis);
/* Returns true if all uninitialized opnds are pruned. Returns false /* Returns true if all uninitialized opnds are pruned. Returns false
otherwise. PHI is the phi node with uninitialized operands, otherwise. PHI is the phi node with uninitialized operands,
...@@ -990,7 +990,7 @@ is_use_properly_guarded (gimple *use_stmt, ...@@ -990,7 +990,7 @@ is_use_properly_guarded (gimple *use_stmt,
Example scenario: Example scenario:
BB1: BB1:
flag_1 = phi <0, 1> // (1) flag_1 = phi <0, 1> // (1)
var_1 = phi <undef, some_val> var_1 = phi <undef, some_val>
...@@ -1001,7 +1001,7 @@ is_use_properly_guarded (gimple *use_stmt, ...@@ -1001,7 +1001,7 @@ is_use_properly_guarded (gimple *use_stmt,
goto BB3; goto BB3;
BB3: BB3:
use of var_2 // (3) use of var_2 // (3)
Because some flag arg in (1) is not constant, if we do not look into the Because some flag arg in (1) is not constant, if we do not look into the
flag phis recursively, it is conservatively treated as unknown and var_1 flag phis recursively, it is conservatively treated as unknown and var_1
...@@ -1027,77 +1027,77 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, ...@@ -1027,77 +1027,77 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi,
tree flag_arg; tree flag_arg;
if (!MASK_TEST_BIT (uninit_opnds, i)) if (!MASK_TEST_BIT (uninit_opnds, i))
continue; continue;
flag_arg = gimple_phi_arg_def (flag_def, i); flag_arg = gimple_phi_arg_def (flag_def, i);
if (!is_gimple_constant (flag_arg)) if (!is_gimple_constant (flag_arg))
{ {
gphi *flag_arg_def, *phi_arg_def; gphi *flag_arg_def, *phi_arg_def;
tree phi_arg; tree phi_arg;
unsigned uninit_opnds_arg_phi; unsigned uninit_opnds_arg_phi;
if (TREE_CODE (flag_arg) != SSA_NAME) if (TREE_CODE (flag_arg) != SSA_NAME)
return false; return false;
flag_arg_def = dyn_cast <gphi *> (SSA_NAME_DEF_STMT (flag_arg)); flag_arg_def = dyn_cast <gphi *> (SSA_NAME_DEF_STMT (flag_arg));
if (!flag_arg_def) if (!flag_arg_def)
return false; return false;
phi_arg = gimple_phi_arg_def (phi, i); phi_arg = gimple_phi_arg_def (phi, i);
if (TREE_CODE (phi_arg) != SSA_NAME) if (TREE_CODE (phi_arg) != SSA_NAME)
return false; return false;
phi_arg_def = dyn_cast <gphi *> (SSA_NAME_DEF_STMT (phi_arg)); phi_arg_def = dyn_cast <gphi *> (SSA_NAME_DEF_STMT (phi_arg));
if (!phi_arg_def) if (!phi_arg_def)
return false; return false;
if (gimple_bb (phi_arg_def) != gimple_bb (flag_arg_def)) if (gimple_bb (phi_arg_def) != gimple_bb (flag_arg_def))
return false; return false;
if (!*visited_flag_phis) if (!*visited_flag_phis)
*visited_flag_phis = BITMAP_ALLOC (NULL); *visited_flag_phis = BITMAP_ALLOC (NULL);
if (bitmap_bit_p (*visited_flag_phis, if (bitmap_bit_p (*visited_flag_phis,
SSA_NAME_VERSION (gimple_phi_result (flag_arg_def)))) SSA_NAME_VERSION (gimple_phi_result (flag_arg_def))))
return false; return false;
bitmap_set_bit (*visited_flag_phis, bitmap_set_bit (*visited_flag_phis,
SSA_NAME_VERSION (gimple_phi_result (flag_arg_def))); SSA_NAME_VERSION (gimple_phi_result (flag_arg_def)));
/* Now recursively prune the uninitialized phi args. */ /* Now recursively prune the uninitialized phi args. */
uninit_opnds_arg_phi = compute_uninit_opnds_pos (phi_arg_def); uninit_opnds_arg_phi = compute_uninit_opnds_pos (phi_arg_def);
if (!prune_uninit_phi_opnds_in_unrealizable_paths if (!prune_uninit_phi_opnds_in_unrealizable_paths
(phi_arg_def, uninit_opnds_arg_phi, flag_arg_def, (phi_arg_def, uninit_opnds_arg_phi, flag_arg_def,
boundary_cst, cmp_code, visited_phis, visited_flag_phis)) boundary_cst, cmp_code, visited_phis, visited_flag_phis))
return false; return false;
bitmap_clear_bit (*visited_flag_phis, bitmap_clear_bit (*visited_flag_phis,
SSA_NAME_VERSION (gimple_phi_result (flag_arg_def))); SSA_NAME_VERSION (gimple_phi_result (flag_arg_def)));
continue; continue;
} }
/* Now check if the constant is in the guarded range. */ /* Now check if the constant is in the guarded range. */
if (is_value_included_in (flag_arg, boundary_cst, cmp_code)) if (is_value_included_in (flag_arg, boundary_cst, cmp_code))
{ {
tree opnd; tree opnd;
gimple *opnd_def; gimple *opnd_def;
/* Now that we know that this undefined edge is not /* Now that we know that this undefined edge is not
pruned. If the operand is defined by another phi, pruned. If the operand is defined by another phi,
we can further prune the incoming edges of that we can further prune the incoming edges of that
phi by checking the predicates of this operands. */ phi by checking the predicates of this operands. */
opnd = gimple_phi_arg_def (phi, i); opnd = gimple_phi_arg_def (phi, i);
opnd_def = SSA_NAME_DEF_STMT (opnd); opnd_def = SSA_NAME_DEF_STMT (opnd);
if (gphi *opnd_def_phi = dyn_cast <gphi *> (opnd_def)) if (gphi *opnd_def_phi = dyn_cast <gphi *> (opnd_def))
{ {
edge opnd_edge; edge opnd_edge;
unsigned uninit_opnds2 unsigned uninit_opnds2
= compute_uninit_opnds_pos (opnd_def_phi); = compute_uninit_opnds_pos (opnd_def_phi);
pred_chain_union def_preds = vNULL; pred_chain_union def_preds = vNULL;
bool ok; bool ok;
gcc_assert (!MASK_EMPTY (uninit_opnds2)); gcc_assert (!MASK_EMPTY (uninit_opnds2));
opnd_edge = gimple_phi_arg_edge (phi, i); opnd_edge = gimple_phi_arg_edge (phi, i);
ok = is_use_properly_guarded (phi, ok = is_use_properly_guarded (phi,
opnd_edge->src, opnd_edge->src,
opnd_def_phi, opnd_def_phi,
uninit_opnds2, uninit_opnds2,
...@@ -1106,10 +1106,10 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, ...@@ -1106,10 +1106,10 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi,
destroy_predicate_vecs (&def_preds); destroy_predicate_vecs (&def_preds);
if (!ok) if (!ok)
return false; return false;
} }
else else
return false; return false;
} }
} }
return true; return true;
...@@ -1119,50 +1119,50 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, ...@@ -1119,50 +1119,50 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi,
of the use is not overlapping with that of the uninit paths. of the use is not overlapping with that of the uninit paths.
The most common senario of guarded use is in Example 1: The most common senario of guarded use is in Example 1:
Example 1: Example 1:
if (some_cond) if (some_cond)
{ {
x = ...; x = ...;
flag = true; flag = true;
} }
... some code ... ... some code ...
if (flag) if (flag)
use (x); use (x);
The real world examples are usually more complicated, but similar The real world examples are usually more complicated, but similar
and usually result from inlining: and usually result from inlining:
bool init_func (int * x) bool init_func (int * x)
{ {
if (some_cond) if (some_cond)
return false; return false;
*x = .. *x = ..
return true; return true;
} }
void foo(..) void foo(..)
{ {
int x; int x;
if (!init_func(&x)) if (!init_func(&x))
return; return;
.. some_code ... .. some_code ...
use (x); use (x);
} }
Another possible use scenario is in the following trivial example: Another possible use scenario is in the following trivial example:
Example 2: Example 2:
if (n > 0) if (n > 0)
x = 1; x = 1;
... ...
if (n > 0) if (n > 0)
{ {
if (m < 2) if (m < 2)
.. = x; .. = x;
} }
Predicate analysis needs to compute the composite predicate: Predicate analysis needs to compute the composite predicate:
...@@ -1173,8 +1173,8 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, ...@@ -1173,8 +1173,8 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi,
bb and is dominating the operand def.) bb and is dominating the operand def.)
and check overlapping: and check overlapping:
(n > 0) .AND. (m < 2) .AND. (.NOT. (n > 0)) (n > 0) .AND. (m < 2) .AND. (.NOT. (n > 0))
<==> false <==> false
This implementation provides framework that can handle This implementation provides framework that can handle
scenarios. (Note that many simple cases are handled properly scenarios. (Note that many simple cases are handled properly
...@@ -1191,7 +1191,7 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, ...@@ -1191,7 +1191,7 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi,
static bool static bool
use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds, use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds,
gphi *phi, unsigned uninit_opnds, gphi *phi, unsigned uninit_opnds,
hash_set<gphi *> *visited_phis) hash_set<gphi *> *visited_phis)
{ {
unsigned int i, n; unsigned int i, n;
...@@ -1223,32 +1223,32 @@ use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds, ...@@ -1223,32 +1223,32 @@ use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds,
cmp_code = the_pred.cond_code; cmp_code = the_pred.cond_code;
if (cond_lhs != NULL_TREE && TREE_CODE (cond_lhs) == SSA_NAME if (cond_lhs != NULL_TREE && TREE_CODE (cond_lhs) == SSA_NAME
&& cond_rhs != NULL_TREE && is_gimple_constant (cond_rhs)) && cond_rhs != NULL_TREE && is_gimple_constant (cond_rhs))
{ {
boundary_cst = cond_rhs; boundary_cst = cond_rhs;
flag = cond_lhs; flag = cond_lhs;
} }
else if (cond_rhs != NULL_TREE && TREE_CODE (cond_rhs) == SSA_NAME else if (cond_rhs != NULL_TREE && TREE_CODE (cond_rhs) == SSA_NAME
&& cond_lhs != NULL_TREE && is_gimple_constant (cond_lhs)) && cond_lhs != NULL_TREE && is_gimple_constant (cond_lhs))
{ {
boundary_cst = cond_lhs; boundary_cst = cond_lhs;
flag = cond_rhs; flag = cond_rhs;
swap_cond = true; swap_cond = true;
} }
if (!flag) if (!flag)
continue; continue;
flag_def = SSA_NAME_DEF_STMT (flag); flag_def = SSA_NAME_DEF_STMT (flag);
if (!flag_def) if (!flag_def)
continue; continue;
if ((gimple_code (flag_def) == GIMPLE_PHI) if ((gimple_code (flag_def) == GIMPLE_PHI)
&& (gimple_bb (flag_def) == gimple_bb (phi)) && (gimple_bb (flag_def) == gimple_bb (phi))
&& find_matching_predicate_in_rest_chains (the_pred, preds, && find_matching_predicate_in_rest_chains (the_pred, preds,
num_preds)) num_preds))
break; break;
flag_def = 0; flag_def = 0;
} }
...@@ -1264,12 +1264,12 @@ use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds, ...@@ -1264,12 +1264,12 @@ use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds,
return false; return false;
all_pruned = prune_uninit_phi_opnds_in_unrealizable_paths (phi, all_pruned = prune_uninit_phi_opnds_in_unrealizable_paths (phi,
uninit_opnds, uninit_opnds,
as_a <gphi *> (flag_def), as_a <gphi *> (flag_def),
boundary_cst, boundary_cst,
cmp_code, cmp_code,
visited_phis, visited_phis,
&visited_flag_phis); &visited_flag_phis);
if (visited_flag_phis) if (visited_flag_phis)
BITMAP_FREE (visited_flag_phis); BITMAP_FREE (visited_flag_phis);
...@@ -1305,13 +1305,13 @@ static inline bool ...@@ -1305,13 +1305,13 @@ static inline bool
is_neq_relop_p (pred_info pred) is_neq_relop_p (pred_info pred)
{ {
return (pred.cond_code == NE_EXPR && !pred.invert) return (pred.cond_code == NE_EXPR && !pred.invert)
|| (pred.cond_code == EQ_EXPR && pred.invert); || (pred.cond_code == EQ_EXPR && pred.invert);
} }
/* Returns true if pred is of the form X != 0. */ /* Returns true if pred is of the form X != 0. */
static inline bool static inline bool
is_neq_zero_form_p (pred_info pred) is_neq_zero_form_p (pred_info pred)
{ {
if (!is_neq_relop_p (pred) || !integer_zerop (pred.pred_rhs) if (!is_neq_relop_p (pred) || !integer_zerop (pred.pred_rhs)
...@@ -1377,7 +1377,7 @@ is_pred_expr_subset_of (pred_info expr1, pred_info expr2) ...@@ -1377,7 +1377,7 @@ is_pred_expr_subset_of (pred_info expr1, pred_info expr2)
static bool static bool
is_pred_chain_subset_of (pred_chain pred1, is_pred_chain_subset_of (pred_chain pred1,
pred_chain pred2) pred_chain pred2)
{ {
size_t np1, np2, i1, i2; size_t np1, np2, i1, i2;
...@@ -1389,16 +1389,16 @@ is_pred_chain_subset_of (pred_chain pred1, ...@@ -1389,16 +1389,16 @@ is_pred_chain_subset_of (pred_chain pred1,
bool found = false; bool found = false;
pred_info info2 = pred2[i2]; pred_info info2 = pred2[i2];
for (i1 = 0; i1 < np1; i1++) for (i1 = 0; i1 < np1; i1++)
{ {
pred_info info1 = pred1[i1]; pred_info info1 = pred1[i1];
if (is_pred_expr_subset_of (info1, info2)) if (is_pred_expr_subset_of (info1, info2))
{ {
found = true; found = true;
break; break;
} }
} }
if (!found) if (!found)
return false; return false;
} }
return true; return true;
} }
...@@ -1421,7 +1421,7 @@ is_included_in (pred_chain one_pred, pred_chain_union preds) ...@@ -1421,7 +1421,7 @@ is_included_in (pred_chain one_pred, pred_chain_union preds)
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
if (is_pred_chain_subset_of (one_pred, preds[i])) if (is_pred_chain_subset_of (one_pred, preds[i]))
return true; return true;
} }
return false; return false;
...@@ -1452,7 +1452,7 @@ is_superset_of (pred_chain_union preds1, pred_chain_union preds2) ...@@ -1452,7 +1452,7 @@ is_superset_of (pred_chain_union preds1, pred_chain_union preds2)
{ {
one_pred_chain = preds2[i]; one_pred_chain = preds2[i];
if (!is_included_in (one_pred_chain, preds1)) if (!is_included_in (one_pred_chain, preds1))
return false; return false;
} }
return true; return true;
...@@ -1464,8 +1464,8 @@ static inline bool ...@@ -1464,8 +1464,8 @@ static inline bool
is_and_or_or_p (enum tree_code tc, tree type) is_and_or_or_p (enum tree_code tc, tree type)
{ {
return (tc == BIT_IOR_EXPR return (tc == BIT_IOR_EXPR
|| (tc == BIT_AND_EXPR || (tc == BIT_AND_EXPR
&& (type == 0 || TREE_CODE (type) == BOOLEAN_TYPE))); && (type == 0 || TREE_CODE (type) == BOOLEAN_TYPE)));
} }
/* Returns true if X1 is the negate of X2. */ /* Returns true if X1 is the negate of X2. */
...@@ -1477,7 +1477,7 @@ pred_neg_p (pred_info x1, pred_info x2) ...@@ -1477,7 +1477,7 @@ pred_neg_p (pred_info x1, pred_info x2)
if (!operand_equal_p (x1.pred_lhs, x2.pred_lhs, 0) if (!operand_equal_p (x1.pred_lhs, x2.pred_lhs, 0)
|| !operand_equal_p (x1.pred_rhs, x2.pred_rhs, 0)) || !operand_equal_p (x1.pred_rhs, x2.pred_rhs, 0))
return false; return false;
c1 = x1.cond_code; c1 = x1.cond_code;
if (x1.invert == x2.invert) if (x1.invert == x2.invert)
c2 = invert_tree_comparison (x2.cond_code, false); c2 = invert_tree_comparison (x2.cond_code, false);
...@@ -1493,7 +1493,7 @@ pred_neg_p (pred_info x1, pred_info x2) ...@@ -1493,7 +1493,7 @@ pred_neg_p (pred_info x1, pred_info x2)
4) ((x IAND y) != 0) || (x != 0 AND y != 0)) is equivalent to 4) ((x IAND y) != 0) || (x != 0 AND y != 0)) is equivalent to
(x != 0 AND y != 0) (x != 0 AND y != 0)
5) (X AND Y) OR (!X AND Z) OR (!Y AND Z) is equivalent to 5) (X AND Y) OR (!X AND Z) OR (!Y AND Z) is equivalent to
(X AND Y) OR Z (X AND Y) OR Z
PREDS is the predicate chains, and N is the number of chains. */ PREDS is the predicate chains, and N is the number of chains. */
...@@ -1514,35 +1514,35 @@ simplify_pred (pred_chain *one_chain) ...@@ -1514,35 +1514,35 @@ simplify_pred (pred_chain *one_chain)
pred_info *a_pred = &(*one_chain)[i]; pred_info *a_pred = &(*one_chain)[i];
if (!a_pred->pred_lhs) if (!a_pred->pred_lhs)
continue; continue;
if (!is_neq_zero_form_p (*a_pred)) if (!is_neq_zero_form_p (*a_pred))
continue; continue;
gimple *def_stmt = SSA_NAME_DEF_STMT (a_pred->pred_lhs); gimple *def_stmt = SSA_NAME_DEF_STMT (a_pred->pred_lhs);
if (gimple_code (def_stmt) != GIMPLE_ASSIGN) if (gimple_code (def_stmt) != GIMPLE_ASSIGN)
continue; continue;
if (gimple_assign_rhs_code (def_stmt) == BIT_IOR_EXPR) if (gimple_assign_rhs_code (def_stmt) == BIT_IOR_EXPR)
{ {
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
{ {
pred_info *b_pred = &(*one_chain)[j]; pred_info *b_pred = &(*one_chain)[j];
if (!b_pred->pred_lhs) if (!b_pred->pred_lhs)
continue; continue;
if (!is_neq_zero_form_p (*b_pred)) if (!is_neq_zero_form_p (*b_pred))
continue; continue;
if (pred_expr_equal_p (*b_pred, gimple_assign_rhs1 (def_stmt)) if (pred_expr_equal_p (*b_pred, gimple_assign_rhs1 (def_stmt))
|| pred_expr_equal_p (*b_pred, gimple_assign_rhs2 (def_stmt))) || pred_expr_equal_p (*b_pred, gimple_assign_rhs2 (def_stmt)))
{ {
/* Mark a_pred for removal. */ /* Mark a_pred for removal. */
a_pred->pred_lhs = NULL; a_pred->pred_lhs = NULL;
a_pred->pred_rhs = NULL; a_pred->pred_rhs = NULL;
simplified = true; simplified = true;
break; break;
} }
} }
} }
} }
if (!simplified) if (!simplified)
...@@ -1552,7 +1552,7 @@ simplify_pred (pred_chain *one_chain) ...@@ -1552,7 +1552,7 @@ simplify_pred (pred_chain *one_chain)
{ {
pred_info *a_pred = &(*one_chain)[i]; pred_info *a_pred = &(*one_chain)[i];
if (!a_pred->pred_lhs) if (!a_pred->pred_lhs)
continue; continue;
s_chain.safe_push (*a_pred); s_chain.safe_push (*a_pred);
} }
...@@ -1572,7 +1572,7 @@ simplify_preds_2 (pred_chain_union *preds) ...@@ -1572,7 +1572,7 @@ simplify_preds_2 (pred_chain_union *preds)
bool simplified = false; bool simplified = false;
pred_chain_union s_preds = vNULL; pred_chain_union s_preds = vNULL;
/* (X AND Y) OR (!X AND Y) is equivalent to Y. /* (X AND Y) OR (!X AND Y) is equivalent to Y.
(X AND Y) OR (X AND !Y) is equivalent to X. */ (X AND Y) OR (X AND !Y) is equivalent to X. */
n = preds->length (); n = preds->length ();
...@@ -1582,55 +1582,55 @@ simplify_preds_2 (pred_chain_union *preds) ...@@ -1582,55 +1582,55 @@ simplify_preds_2 (pred_chain_union *preds)
pred_chain *a_chain = &(*preds)[i]; pred_chain *a_chain = &(*preds)[i];
if (a_chain->length () != 2) if (a_chain->length () != 2)
continue; continue;
x = (*a_chain)[0]; x = (*a_chain)[0];
y = (*a_chain)[1]; y = (*a_chain)[1];
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
{ {
pred_chain *b_chain; pred_chain *b_chain;
pred_info x2, y2; pred_info x2, y2;
if (j == i) if (j == i)
continue; continue;
b_chain = &(*preds)[j]; b_chain = &(*preds)[j];
if (b_chain->length () != 2) if (b_chain->length () != 2)
continue; continue;
x2 = (*b_chain)[0]; x2 = (*b_chain)[0];
y2 = (*b_chain)[1]; y2 = (*b_chain)[1];
if (pred_equal_p (x, x2) && pred_neg_p (y, y2)) if (pred_equal_p (x, x2) && pred_neg_p (y, y2))
{ {
/* Kill a_chain. */ /* Kill a_chain. */
a_chain->release (); a_chain->release ();
b_chain->release (); b_chain->release ();
b_chain->safe_push (x); b_chain->safe_push (x);
simplified = true; simplified = true;
break; break;
} }
if (pred_neg_p (x, x2) && pred_equal_p (y, y2)) if (pred_neg_p (x, x2) && pred_equal_p (y, y2))
{ {
/* Kill a_chain. */ /* Kill a_chain. */
a_chain->release (); a_chain->release ();
b_chain->release (); b_chain->release ();
b_chain->safe_push (y); b_chain->safe_push (y);
simplified = true; simplified = true;
break; break;
} }
} }
} }
/* Now clean up the chain. */ /* Now clean up the chain. */
if (simplified) if (simplified)
{ {
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
if ((*preds)[i].is_empty ()) if ((*preds)[i].is_empty ())
continue; continue;
s_preds.safe_push ((*preds)[i]); s_preds.safe_push ((*preds)[i]);
} }
preds->release (); preds->release ();
(*preds) = s_preds; (*preds) = s_preds;
s_preds = vNULL; s_preds = vNULL;
...@@ -1663,34 +1663,34 @@ simplify_preds_3 (pred_chain_union *preds) ...@@ -1663,34 +1663,34 @@ simplify_preds_3 (pred_chain_union *preds)
pred_chain *a_chain = &(*preds)[i]; pred_chain *a_chain = &(*preds)[i];
if (a_chain->length () != 1) if (a_chain->length () != 1)
continue; continue;
x = (*a_chain)[0]; x = (*a_chain)[0];
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
{ {
pred_chain *b_chain; pred_chain *b_chain;
pred_info x2; pred_info x2;
size_t k; size_t k;
if (j == i) if (j == i)
continue; continue;
b_chain = &(*preds)[j]; b_chain = &(*preds)[j];
if (b_chain->length () < 2) if (b_chain->length () < 2)
continue; continue;
for (k = 0; k < b_chain->length (); k++) for (k = 0; k < b_chain->length (); k++)
{ {
x2 = (*b_chain)[k]; x2 = (*b_chain)[k];
if (pred_neg_p (x, x2)) if (pred_neg_p (x, x2))
{ {
b_chain->unordered_remove (k); b_chain->unordered_remove (k);
simplified = true; simplified = true;
break; break;
} }
} }
} }
} }
return simplified; return simplified;
} }
...@@ -1716,59 +1716,59 @@ simplify_preds_4 (pred_chain_union *preds) ...@@ -1716,59 +1716,59 @@ simplify_preds_4 (pred_chain_union *preds)
pred_chain *a_chain = &(*preds)[i]; pred_chain *a_chain = &(*preds)[i];
if (a_chain->length () != 1) if (a_chain->length () != 1)
continue; continue;
z = (*a_chain)[0]; z = (*a_chain)[0];
if (!is_neq_zero_form_p (z)) if (!is_neq_zero_form_p (z))
continue; continue;
def_stmt = SSA_NAME_DEF_STMT (z.pred_lhs); def_stmt = SSA_NAME_DEF_STMT (z.pred_lhs);
if (gimple_code (def_stmt) != GIMPLE_ASSIGN) if (gimple_code (def_stmt) != GIMPLE_ASSIGN)
continue; continue;
if (gimple_assign_rhs_code (def_stmt) != BIT_AND_EXPR) if (gimple_assign_rhs_code (def_stmt) != BIT_AND_EXPR)
continue; continue;
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
{ {
pred_chain *b_chain; pred_chain *b_chain;
pred_info x2, y2; pred_info x2, y2;
if (j == i) if (j == i)
continue; continue;
b_chain = &(*preds)[j]; b_chain = &(*preds)[j];
if (b_chain->length () != 2) if (b_chain->length () != 2)
continue; continue;
x2 = (*b_chain)[0]; x2 = (*b_chain)[0];
y2 = (*b_chain)[1]; y2 = (*b_chain)[1];
if (!is_neq_zero_form_p (x2) if (!is_neq_zero_form_p (x2)
|| !is_neq_zero_form_p (y2)) || !is_neq_zero_form_p (y2))
continue; continue;
if ((pred_expr_equal_p (x2, gimple_assign_rhs1 (def_stmt)) if ((pred_expr_equal_p (x2, gimple_assign_rhs1 (def_stmt))
&& pred_expr_equal_p (y2, gimple_assign_rhs2 (def_stmt))) && pred_expr_equal_p (y2, gimple_assign_rhs2 (def_stmt)))
|| (pred_expr_equal_p (x2, gimple_assign_rhs2 (def_stmt)) || (pred_expr_equal_p (x2, gimple_assign_rhs2 (def_stmt))
&& pred_expr_equal_p (y2, gimple_assign_rhs1 (def_stmt)))) && pred_expr_equal_p (y2, gimple_assign_rhs1 (def_stmt))))
{ {
/* Kill a_chain. */ /* Kill a_chain. */
a_chain->release (); a_chain->release ();
simplified = true; simplified = true;
break; break;
} }
} }
} }
/* Now clean up the chain. */ /* Now clean up the chain. */
if (simplified) if (simplified)
{ {
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
if ((*preds)[i].is_empty ()) if ((*preds)[i].is_empty ())
continue; continue;
s_preds.safe_push ((*preds)[i]); s_preds.safe_push ((*preds)[i]);
} }
destroy_predicate_vecs (preds); destroy_predicate_vecs (preds);
(*preds) = s_preds; (*preds) = s_preds;
...@@ -1804,15 +1804,15 @@ simplify_preds (pred_chain_union *preds, gimple *use_or_def, bool is_use) ...@@ -1804,15 +1804,15 @@ simplify_preds (pred_chain_union *preds, gimple *use_or_def, bool is_use)
{ {
changed = false; changed = false;
if (simplify_preds_2 (preds)) if (simplify_preds_2 (preds))
changed = true; changed = true;
/* Now iteratively simplify X OR (!X AND Z ..) /* Now iteratively simplify X OR (!X AND Z ..)
into X OR (Z ...). */ into X OR (Z ...). */
if (simplify_preds_3 (preds)) if (simplify_preds_3 (preds))
changed = true; changed = true;
if (simplify_preds_4 (preds)) if (simplify_preds_4 (preds))
changed = true; changed = true;
} while (changed); } while (changed);
...@@ -1821,7 +1821,7 @@ simplify_preds (pred_chain_union *preds, gimple *use_or_def, bool is_use) ...@@ -1821,7 +1821,7 @@ simplify_preds (pred_chain_union *preds, gimple *use_or_def, bool is_use)
/* This is a helper function which attempts to normalize predicate chains /* This is a helper function which attempts to normalize predicate chains
by following UD chains. It basically builds up a big tree of either IOR by following UD chains. It basically builds up a big tree of either IOR
operations or AND operations, and convert the IOR tree into a operations or AND operations, and convert the IOR tree into a
pred_chain_union or BIT_AND tree into a pred_chain. pred_chain_union or BIT_AND tree into a pred_chain.
Example: Example:
...@@ -1846,7 +1846,7 @@ simplify_preds (pred_chain_union *preds, gimple *use_or_def, bool is_use) ...@@ -1846,7 +1846,7 @@ simplify_preds (pred_chain_union *preds, gimple *use_or_def, bool is_use)
then _t != 0 will be normalized into a pred_chain: then _t != 0 will be normalized into a pred_chain:
(_2 RELOP1 _1) AND (_5 RELOP2 _4) AND (_8 RELOP3 _7) AND (_0 != 0) (_2 RELOP1 _1) AND (_5 RELOP2 _4) AND (_8 RELOP3 _7) AND (_0 != 0)
*/ */
/* This is a helper function that stores a PRED into NORM_PREDS. */ /* This is a helper function that stores a PRED into NORM_PREDS. */
...@@ -1864,7 +1864,7 @@ push_pred (pred_chain_union *norm_preds, pred_info pred) ...@@ -1864,7 +1864,7 @@ push_pred (pred_chain_union *norm_preds, pred_info pred)
inline static void inline static void
push_to_worklist (tree op, vec<pred_info, va_heap, vl_ptr> *work_list, push_to_worklist (tree op, vec<pred_info, va_heap, vl_ptr> *work_list,
hash_set<tree> *mark_set) hash_set<tree> *mark_set)
{ {
if (mark_set->contains (op)) if (mark_set->contains (op))
return; return;
...@@ -1925,52 +1925,52 @@ is_degenerated_phi (gimple *phi, pred_info *pred_p) ...@@ -1925,52 +1925,52 @@ is_degenerated_phi (gimple *phi, pred_info *pred_p)
tree op = gimple_phi_arg_def (phi, i); tree op = gimple_phi_arg_def (phi, i);
if (TREE_CODE (op) != SSA_NAME) if (TREE_CODE (op) != SSA_NAME)
return false; return false;
def = SSA_NAME_DEF_STMT (op); def = SSA_NAME_DEF_STMT (op);
if (gimple_code (def) != GIMPLE_ASSIGN) if (gimple_code (def) != GIMPLE_ASSIGN)
return false; return false;
if (TREE_CODE_CLASS (gimple_assign_rhs_code (def)) if (TREE_CODE_CLASS (gimple_assign_rhs_code (def))
!= tcc_comparison) != tcc_comparison)
return false; return false;
pred = get_pred_info_from_cmp (def); pred = get_pred_info_from_cmp (def);
if (!pred_equal_p (pred, pred0)) if (!pred_equal_p (pred, pred0))
return false; return false;
} }
*pred_p = pred0; *pred_p = pred0;
return true; return true;
} }
/* Normalize one predicate PRED /* Normalize one predicate PRED
1) if PRED can no longer be normlized, put it into NORM_PREDS. 1) if PRED can no longer be normlized, put it into NORM_PREDS.
2) otherwise if PRED is of the form x != 0, follow x's definition 2) otherwise if PRED is of the form x != 0, follow x's definition
and put normalized predicates into WORK_LIST. */ and put normalized predicates into WORK_LIST. */
static void static void
normalize_one_pred_1 (pred_chain_union *norm_preds, normalize_one_pred_1 (pred_chain_union *norm_preds,
pred_chain *norm_chain, pred_chain *norm_chain,
pred_info pred, pred_info pred,
enum tree_code and_or_code, enum tree_code and_or_code,
vec<pred_info, va_heap, vl_ptr> *work_list, vec<pred_info, va_heap, vl_ptr> *work_list,
hash_set<tree> *mark_set) hash_set<tree> *mark_set)
{ {
if (!is_neq_zero_form_p (pred)) if (!is_neq_zero_form_p (pred))
{ {
if (and_or_code == BIT_IOR_EXPR) if (and_or_code == BIT_IOR_EXPR)
push_pred (norm_preds, pred); push_pred (norm_preds, pred);
else else
norm_chain->safe_push (pred); norm_chain->safe_push (pred);
return; return;
} }
gimple *def_stmt = SSA_NAME_DEF_STMT (pred.pred_lhs); gimple *def_stmt = SSA_NAME_DEF_STMT (pred.pred_lhs);
if (gimple_code (def_stmt) == GIMPLE_PHI if (gimple_code (def_stmt) == GIMPLE_PHI
&& is_degenerated_phi (def_stmt, &pred)) && is_degenerated_phi (def_stmt, &pred))
work_list->safe_push (pred); work_list->safe_push (pred);
else if (gimple_code (def_stmt) == GIMPLE_PHI else if (gimple_code (def_stmt) == GIMPLE_PHI
&& and_or_code == BIT_IOR_EXPR) && and_or_code == BIT_IOR_EXPR)
{ {
int i, n; int i, n;
n = gimple_phi_num_args (def_stmt); n = gimple_phi_num_args (def_stmt);
...@@ -1978,23 +1978,23 @@ normalize_one_pred_1 (pred_chain_union *norm_preds, ...@@ -1978,23 +1978,23 @@ normalize_one_pred_1 (pred_chain_union *norm_preds,
/* If we see non zero constant, we should punt. The predicate /* If we see non zero constant, we should punt. The predicate
* should be one guarding the phi edge. */ * should be one guarding the phi edge. */
for (i = 0; i < n; ++i) for (i = 0; i < n; ++i)
{ {
tree op = gimple_phi_arg_def (def_stmt, i); tree op = gimple_phi_arg_def (def_stmt, i);
if (TREE_CODE (op) == INTEGER_CST && !integer_zerop (op)) if (TREE_CODE (op) == INTEGER_CST && !integer_zerop (op))
{ {
push_pred (norm_preds, pred); push_pred (norm_preds, pred);
return; return;
} }
} }
for (i = 0; i < n; ++i) for (i = 0; i < n; ++i)
{ {
tree op = gimple_phi_arg_def (def_stmt, i); tree op = gimple_phi_arg_def (def_stmt, i);
if (integer_zerop (op)) if (integer_zerop (op))
continue; continue;
push_to_worklist (op, work_list, mark_set); push_to_worklist (op, work_list, mark_set);
} }
} }
else if (gimple_code (def_stmt) != GIMPLE_ASSIGN) else if (gimple_code (def_stmt) != GIMPLE_ASSIGN)
{ {
...@@ -2047,7 +2047,7 @@ normalize_one_pred_1 (pred_chain_union *norm_preds, ...@@ -2047,7 +2047,7 @@ normalize_one_pred_1 (pred_chain_union *norm_preds,
static void static void
normalize_one_pred (pred_chain_union *norm_preds, normalize_one_pred (pred_chain_union *norm_preds,
pred_info pred) pred_info pred)
{ {
vec<pred_info, va_heap, vl_ptr> work_list = vNULL; vec<pred_info, va_heap, vl_ptr> work_list = vNULL;
enum tree_code and_or_code = ERROR_MARK; enum tree_code and_or_code = ERROR_MARK;
...@@ -2066,13 +2066,13 @@ normalize_one_pred (pred_chain_union *norm_preds, ...@@ -2066,13 +2066,13 @@ normalize_one_pred (pred_chain_union *norm_preds,
&& and_or_code != BIT_AND_EXPR) && and_or_code != BIT_AND_EXPR)
{ {
if (TREE_CODE_CLASS (and_or_code) if (TREE_CODE_CLASS (and_or_code)
== tcc_comparison) == tcc_comparison)
{ {
pred_info n_pred = get_pred_info_from_cmp (def_stmt); pred_info n_pred = get_pred_info_from_cmp (def_stmt);
push_pred (norm_preds, n_pred); push_pred (norm_preds, n_pred);
} }
else else
push_pred (norm_preds, pred); push_pred (norm_preds, pred);
return; return;
} }
...@@ -2083,7 +2083,7 @@ normalize_one_pred (pred_chain_union *norm_preds, ...@@ -2083,7 +2083,7 @@ normalize_one_pred (pred_chain_union *norm_preds,
{ {
pred_info a_pred = work_list.pop (); pred_info a_pred = work_list.pop ();
normalize_one_pred_1 (norm_preds, &norm_chain, a_pred, normalize_one_pred_1 (norm_preds, &norm_chain, a_pred,
and_or_code, &work_list, &mark_set); and_or_code, &work_list, &mark_set);
} }
if (and_or_code == BIT_AND_EXPR) if (and_or_code == BIT_AND_EXPR)
norm_preds->safe_push (norm_chain); norm_preds->safe_push (norm_chain);
...@@ -2093,7 +2093,7 @@ normalize_one_pred (pred_chain_union *norm_preds, ...@@ -2093,7 +2093,7 @@ normalize_one_pred (pred_chain_union *norm_preds,
static void static void
normalize_one_pred_chain (pred_chain_union *norm_preds, normalize_one_pred_chain (pred_chain_union *norm_preds,
pred_chain one_chain) pred_chain one_chain)
{ {
vec<pred_info, va_heap, vl_ptr> work_list = vNULL; vec<pred_info, va_heap, vl_ptr> work_list = vNULL;
hash_set<tree> mark_set; hash_set<tree> mark_set;
...@@ -2110,7 +2110,7 @@ normalize_one_pred_chain (pred_chain_union *norm_preds, ...@@ -2110,7 +2110,7 @@ normalize_one_pred_chain (pred_chain_union *norm_preds,
{ {
pred_info a_pred = work_list.pop (); pred_info a_pred = work_list.pop ();
normalize_one_pred_1 (0, &norm_chain, a_pred, normalize_one_pred_1 (0, &norm_chain, a_pred,
BIT_AND_EXPR, &work_list, &mark_set); BIT_AND_EXPR, &work_list, &mark_set);
} }
norm_preds->safe_push (norm_chain); norm_preds->safe_push (norm_chain);
...@@ -2135,12 +2135,12 @@ normalize_preds (pred_chain_union preds, gimple *use_or_def, bool is_use) ...@@ -2135,12 +2135,12 @@ normalize_preds (pred_chain_union preds, gimple *use_or_def, bool is_use)
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
if (preds[i].length () != 1) if (preds[i].length () != 1)
normalize_one_pred_chain (&norm_preds, preds[i]); normalize_one_pred_chain (&norm_preds, preds[i]);
else else
{ {
normalize_one_pred (&norm_preds, preds[i][0]); normalize_one_pred (&norm_preds, preds[i][0]);
preds[i].release (); preds[i].release ();
} }
} }
if (dump_file) if (dump_file)
...@@ -2177,11 +2177,11 @@ normalize_preds (pred_chain_union preds, gimple *use_or_def, bool is_use) ...@@ -2177,11 +2177,11 @@ normalize_preds (pred_chain_union preds, gimple *use_or_def, bool is_use)
static bool static bool
is_use_properly_guarded (gimple *use_stmt, is_use_properly_guarded (gimple *use_stmt,
basic_block use_bb, basic_block use_bb,
gphi *phi, gphi *phi,
unsigned uninit_opnds, unsigned uninit_opnds,
pred_chain_union *def_preds, pred_chain_union *def_preds,
hash_set<gphi *> *visited_phis) hash_set<gphi *> *visited_phis)
{ {
basic_block phi_bb; basic_block phi_bb;
pred_chain_union preds = vNULL; pred_chain_union preds = vNULL;
...@@ -2249,7 +2249,7 @@ is_use_properly_guarded (gimple *use_stmt, ...@@ -2249,7 +2249,7 @@ is_use_properly_guarded (gimple *use_stmt,
static gimple * static gimple *
find_uninit_use (gphi *phi, unsigned uninit_opnds, find_uninit_use (gphi *phi, unsigned uninit_opnds,
vec<gphi *> *worklist, vec<gphi *> *worklist,
hash_set<gphi *> *added_to_worklist) hash_set<gphi *> *added_to_worklist)
{ {
tree phi_result; tree phi_result;
...@@ -2281,10 +2281,10 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds, ...@@ -2281,10 +2281,10 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds,
continue; continue;
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
fprintf (dump_file, "[CHECK]: Found unguarded use: "); fprintf (dump_file, "[CHECK]: Found unguarded use: ");
print_gimple_stmt (dump_file, use_stmt, 0, 0); print_gimple_stmt (dump_file, use_stmt, 0, 0);
} }
/* Found one real use, return. */ /* Found one real use, return. */
if (gimple_code (use_stmt) != GIMPLE_PHI) if (gimple_code (use_stmt) != GIMPLE_PHI)
{ {
...@@ -2293,18 +2293,18 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds, ...@@ -2293,18 +2293,18 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds,
} }
/* Found a phi use that is not guarded, /* Found a phi use that is not guarded,
add the phi to the worklist. */ add the phi to the worklist. */
if (!added_to_worklist->add (as_a <gphi *> (use_stmt))) if (!added_to_worklist->add (as_a <gphi *> (use_stmt)))
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
fprintf (dump_file, "[WORKLIST]: Update worklist with phi: "); fprintf (dump_file, "[WORKLIST]: Update worklist with phi: ");
print_gimple_stmt (dump_file, use_stmt, 0, 0); print_gimple_stmt (dump_file, use_stmt, 0, 0);
} }
worklist->safe_push (as_a <gphi *> (use_stmt)); worklist->safe_push (as_a <gphi *> (use_stmt));
possibly_undefined_names->add (phi_result); possibly_undefined_names->add (phi_result);
} }
} }
destroy_predicate_vecs (&def_preds); destroy_predicate_vecs (&def_preds);
...@@ -2321,7 +2321,7 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds, ...@@ -2321,7 +2321,7 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds,
static void static void
warn_uninitialized_phi (gphi *phi, vec<gphi *> *worklist, warn_uninitialized_phi (gphi *phi, vec<gphi *> *worklist,
hash_set<gphi *> *added_to_worklist) hash_set<gphi *> *added_to_worklist)
{ {
unsigned uninit_opnds; unsigned uninit_opnds;
gimple *uninit_use_stmt = 0; gimple *uninit_use_stmt = 0;
...@@ -2346,7 +2346,7 @@ warn_uninitialized_phi (gphi *phi, vec<gphi *> *worklist, ...@@ -2346,7 +2346,7 @@ warn_uninitialized_phi (gphi *phi, vec<gphi *> *worklist,
/* Now check if we have any use of the value without proper guard. */ /* Now check if we have any use of the value without proper guard. */
uninit_use_stmt = find_uninit_use (phi, uninit_opnds, uninit_use_stmt = find_uninit_use (phi, uninit_opnds,
worklist, added_to_worklist); worklist, added_to_worklist);
/* All uses are properly guarded. */ /* All uses are properly guarded. */
if (!uninit_use_stmt) if (!uninit_use_stmt)
...@@ -2362,8 +2362,8 @@ warn_uninitialized_phi (gphi *phi, vec<gphi *> *worklist, ...@@ -2362,8 +2362,8 @@ warn_uninitialized_phi (gphi *phi, vec<gphi *> *worklist,
loc = UNKNOWN_LOCATION; loc = UNKNOWN_LOCATION;
warn_uninit (OPT_Wmaybe_uninitialized, uninit_op, SSA_NAME_VAR (uninit_op), warn_uninit (OPT_Wmaybe_uninitialized, uninit_op, SSA_NAME_VAR (uninit_op),
SSA_NAME_VAR (uninit_op), SSA_NAME_VAR (uninit_op),
"%qD may be used uninitialized in this function", "%qD may be used uninitialized in this function",
uninit_use_stmt, loc); uninit_use_stmt, loc);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment