static tree storetemp;
static tree prephitemp;
-/* Set of blocks with statements that have had its EH information
- cleaned up. */
+/* Set of blocks with statements that have had their EH properties changed. */
static bitmap need_eh_cleanup;
+/* Set of blocks with statements that have had their AB properties changed. */
+static bitmap need_ab_cleanup;
+
/* The phi_translate_table caches phi translations for a given
expression and predecessor. */
exprset = VEC_index (bitmap_set_t, value_expressions, lookfor);
FOR_EACH_EXPR_ID_IN_SET (exprset, i, bi)
{
- if (bitmap_bit_p (&set->expressions, i))
+ if (bitmap_clear_bit (&set->expressions, i))
{
- bitmap_clear_bit (&set->expressions, i);
bitmap_set_bit (&set->expressions, get_expression_id (expr));
return;
}
{
unsigned int val = get_expr_value_id (expr);
-#ifdef ENABLE_CHECKING
- gcc_assert (expr->id == get_or_alloc_expression_id (expr));
-#endif
+ gcc_checking_assert (expr->id == get_or_alloc_expression_id (expr));
/* Constant values are always considered to be part of the set. */
if (value_id_constant_p (val))
}
exprs = sorted_array_from_bitmap_set (set);
- for (i = 0; VEC_iterate (pre_expr, exprs, i, expr); i++)
+ FOR_EACH_VEC_ELT (pre_expr, exprs, i, expr)
{
pre_expr translated;
translated = phi_translate (expr, set, NULL, pred, phiblock);
vn_reference_op_t vro;
unsigned int i;
- for (i = 0; VEC_iterate (vn_reference_op_s, ref->operands, i, vro); i++)
+ FOR_EACH_VEC_ELT (vn_reference_op_s, ref->operands, i, vro)
{
if (!vro_valid_in_sets (set1, set2, vro))
return false;
pre_expr expr;
int i;
- for (i = 0; VEC_iterate (pre_expr, exprs, i, expr); i++)
+ FOR_EACH_VEC_ELT (pre_expr, exprs, i, expr)
{
if (!valid_in_sets (set1, set2, expr, block))
bitmap_remove_from_set (set1, expr);
pre_expr expr;
int i;
- for (i = 0; VEC_iterate (pre_expr, exprs, i, expr); i++)
+ FOR_EACH_VEC_ELT (pre_expr, exprs, i, expr)
{
if (!valid_in_sets (set, NULL, expr, block))
bitmap_remove_from_set (set, expr);
else
bitmap_set_copy (ANTIC_OUT, ANTIC_IN (first));
- for (i = 0; VEC_iterate (basic_block, worklist, i, bprime); i++)
+ FOR_EACH_VEC_ELT (basic_block, worklist, i, bprime)
{
if (!gimple_seq_empty_p (phi_nodes (bprime)))
{
}
if (VEC_length (basic_block, worklist) > 0)
{
- for (i = 0; VEC_iterate (basic_block, worklist, i, bprime); i++)
+ FOR_EACH_VEC_ELT (basic_block, worklist, i, bprime)
{
unsigned int i;
bitmap_iterator bi;
block->index));
}
}
-#ifdef ENABLE_CHECKING
/* Theoretically possible, but *highly* unlikely. */
- gcc_assert (num_iterations < 500);
-#endif
+ gcc_checking_assert (num_iterations < 500);
}
statistics_histogram_event (cfun, "compute_antic iterations",
block->index));
}
}
-#ifdef ENABLE_CHECKING
/* Theoretically possible, but *highly* unlikely. */
- gcc_assert (num_iterations < 500);
-#endif
+ gcc_checking_assert (num_iterations < 500);
}
statistics_histogram_event (cfun, "compute_partial_antic iterations",
num_iterations);
break;
case TARGET_MEM_REF:
{
- pre_expr op0expr;
- tree genop0 = NULL_TREE;
+ pre_expr op0expr, op1expr;
+ tree genop0 = NULL_TREE, genop1 = NULL_TREE;
+ vn_reference_op_t nextop = VEC_index (vn_reference_op_s, ref->operands,
+ ++*operand);
tree baseop = create_component_ref_by_pieces_1 (block, ref, operand,
stmts, domstmt);
if (!baseop)
if (!genop0)
return NULL_TREE;
}
- if (DECL_P (baseop))
- return build5 (TARGET_MEM_REF, currop->type,
- baseop, NULL_TREE,
- genop0, currop->op1, currop->op2);
- else
- return build5 (TARGET_MEM_REF, currop->type,
- NULL_TREE, baseop,
- genop0, currop->op1, currop->op2);
+ if (nextop->op0)
+ {
+ op1expr = get_or_alloc_expr_for (nextop->op0);
+ genop1 = find_or_generate_expression (block, op1expr,
+ stmts, domstmt);
+ if (!genop1)
+ return NULL_TREE;
+ }
+ return build5 (TARGET_MEM_REF, currop->type,
+ baseop, currop->op2, genop0, currop->op1, genop1);
}
break;
case ADDR_EXPR:
return folded;
}
break;
- case MISALIGNED_INDIRECT_REF:
- {
- tree folded;
- tree genop1 = create_component_ref_by_pieces_1 (block, ref,
- operand,
- stmts, domstmt);
- if (!genop1)
- return NULL_TREE;
- genop1 = fold_convert (build_pointer_type (currop->type),
- genop1);
-
- if (currop->opcode == MISALIGNED_INDIRECT_REF)
- folded = fold_build2 (currop->opcode, currop->type,
- genop1, currop->op1);
- else
- folded = fold_build1 (currop->opcode, currop->type,
- genop1);
- return folded;
- }
- break;
case BIT_FIELD_REF:
{
tree folded;
memory reference is a simple induction variable. In other
cases the vectorizer won't do anything anyway (either it's
loop invariant or a complicated expression). */
- for (i = 0; VEC_iterate (vn_reference_op_s, ops, i, op); ++i)
+ FOR_EACH_VEC_ELT (vn_reference_op_s, ops, i, op)
{
switch (op->opcode)
{
pre_expr expr;
int i;
- for (i = 0; VEC_iterate (pre_expr, exprs, i, expr); i++)
+ FOR_EACH_VEC_ELT (pre_expr, exprs, i, expr)
{
if (expr->kind != NAME)
{
pre_expr expr;
int i;
- for (i = 0; VEC_iterate (pre_expr, exprs, i, expr); i++)
+ FOR_EACH_VEC_ELT (pre_expr, exprs, i, expr)
{
if (expr->kind != NAME)
{
|| TREE_CODE (rhs) != SSA_NAME
|| may_propagate_copy (rhs, sprime)))
{
+ bool can_make_abnormal_goto
+ = is_gimple_call (stmt)
+ && stmt_can_make_abnormal_goto (stmt);
+
gcc_assert (sprime != rhs);
if (dump_file && (dump_flags & TDF_DETAILS))
stmt = gsi_stmt (gsi);
update_stmt (stmt);
- /* If we removed EH side effects from the statement, clean
+ /* If we removed EH side-effects from the statement, clean
its EH information. */
if (maybe_clean_or_replace_eh_stmt (stmt, stmt))
{
bitmap_set_bit (need_eh_cleanup,
gimple_bb (stmt)->index);
if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, " Removed EH side effects.\n");
+ fprintf (dump_file, " Removed EH side-effects.\n");
+ }
+
+ /* Likewise for AB side-effects. */
+ if (can_make_abnormal_goto
+ && !stmt_can_make_abnormal_goto (stmt))
+ {
+ bitmap_set_bit (need_ab_cleanup,
+ gimple_bb (stmt)->index);
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, " Removed AB side-effects.\n");
}
}
}
}
/* Visit indirect calls and turn them into direct calls if
possible. */
- if (gimple_code (stmt) == GIMPLE_CALL
+ if (is_gimple_call (stmt)
&& TREE_CODE (gimple_call_fn (stmt)) == SSA_NAME)
{
tree fn = VN_INFO (gimple_call_fn (stmt))->valnum;
if (TREE_CODE (fn) == ADDR_EXPR
&& TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL)
{
+ bool can_make_abnormal_goto
+ = stmt_can_make_abnormal_goto (stmt);
+ bool was_noreturn = gimple_call_noreturn_p (stmt);
+
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Replacing call target with ");
gimple_call_set_fn (stmt, fn);
update_stmt (stmt);
+
+ /* When changing a call into a noreturn call, cfg cleanup
+ is needed to fix up the noreturn call. */
+ if (!was_noreturn && gimple_call_noreturn_p (stmt))
+ todo |= TODO_cleanup_cfg;
+
+ /* If we removed EH side-effects from the statement, clean
+ its EH information. */
if (maybe_clean_or_replace_eh_stmt (stmt, stmt))
{
bitmap_set_bit (need_eh_cleanup,
gimple_bb (stmt)->index);
if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, " Removed EH side effects.\n");
+ fprintf (dump_file, " Removed EH side-effects.\n");
+ }
+
+ /* Likewise for AB side-effects. */
+ if (can_make_abnormal_goto
+ && !stmt_can_make_abnormal_goto (stmt))
+ {
+ bitmap_set_bit (need_ab_cleanup,
+ gimple_bb (stmt)->index);
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, " Removed AB side-effects.\n");
}
/* Changing an indirect call to a direct call may
/* We cannot remove stmts during BB walk, especially not release SSA
names there as this confuses the VN machinery. The stmts ending
up in to_remove are either stores or simple copies. */
- for (i = 0; VEC_iterate (gimple, to_remove, i, stmt); ++i)
+ FOR_EACH_VEC_ELT (gimple, to_remove, i, stmt)
{
tree lhs = gimple_assign_lhs (stmt);
tree rhs = gimple_assign_rhs1 (stmt);
if (TREE_CODE (lhs) != SSA_NAME
|| has_zero_uses (lhs))
{
+ basic_block bb = gimple_bb (stmt);
gsi = gsi_for_stmt (stmt);
unlink_stmt_vdef (stmt);
gsi_remove (&gsi, true);
+ if (gimple_purge_dead_eh_edges (bb))
+ todo |= TODO_cleanup_cfg;
if (TREE_CODE (lhs) == SSA_NAME)
bitmap_clear_bit (inserted_exprs, SSA_NAME_VERSION (lhs));
release_defs (stmt);
}
need_eh_cleanup = BITMAP_ALLOC (NULL);
+ need_ab_cleanup = BITMAP_ALLOC (NULL);
}
BITMAP_FREE (need_eh_cleanup);
+ if (!bitmap_empty_p (need_ab_cleanup))
+ {
+ gimple_purge_all_dead_abnormal_call_edges (need_ab_cleanup);
+ cleanup_tree_cfg ();
+ }
+
+ BITMAP_FREE (need_ab_cleanup);
+
if (!do_fre)
loop_optimizer_finalize ();
}