/* Back-propagation of usage information to definitions.
- Copyright (C) 2015-2017 Free Software Foundation, Inc.
+ Copyright (C) 2015-2020 Free Software Foundation, Inc.
This file is part of GCC.
namespace {
/* Information about a group of uses of an SSA name. */
-struct usage_info
+class usage_info
{
+public:
usage_info () : flag_word (0) {}
usage_info &operator &= (const usage_info &);
usage_info operator & (const usage_info &) const;
post-order walk. */
auto_sbitmap m_visited_blocks;
+ /* A bitmap of phis that we have finished processing in the initial
+ post-order walk, excluding those from blocks mentioned in
+ M_VISITED_BLOCKS. */
+ auto_bitmap m_visited_phis;
+
/* A worklist of SSA names whose definitions need to be reconsidered. */
auto_vec <tree, 64> m_worklist;
CASE_CFN_FMA:
CASE_CFN_FMA_FN:
+ case CFN_FMS:
+ case CFN_FNMA:
+ case CFN_FNMS:
/* In X * X + Y, where Y is distinct from X, the sign of X doesn't
matter. */
if (gimple_call_arg (call, 0) == rhs
switch (gimple_assign_rhs_code (assign))
{
case ABS_EXPR:
+ case ABSU_EXPR:
/* The sign of the input doesn't matter. */
info->flags.ignore_sign = true;
break;
}
break;
- case FMA_EXPR:
- /* In X * X + Y, where Y is distinct from X, the sign of X doesn't
- matter. */
- if (gimple_assign_rhs1 (assign) == rhs
- && gimple_assign_rhs2 (assign) == rhs
- && gimple_assign_rhs3 (assign) != rhs)
- info->flags.ignore_sign = true;
- break;
-
case MULT_EXPR:
/* In X * X, the sign of X doesn't matter. */
if (gimple_assign_rhs1 (assign) == rhs
backprop::intersect_uses (tree var, usage_info *info)
{
imm_use_iterator iter;
- gimple *stmt;
+ use_operand_p use_p;
*info = usage_info::intersection_identity ();
- FOR_EACH_IMM_USE_STMT (stmt, iter, var)
+ FOR_EACH_IMM_USE_FAST (use_p, iter, var)
{
+ gimple *stmt = USE_STMT (use_p);
if (is_gimple_debug (stmt))
continue;
- if (is_a <gphi *> (stmt)
- && !bitmap_bit_p (m_visited_blocks, gimple_bb (stmt)->index))
+ gphi *phi = dyn_cast <gphi *> (stmt);
+ if (phi
+ && !bitmap_bit_p (m_visited_blocks, gimple_bb (phi)->index)
+ && !bitmap_bit_p (m_visited_phis,
+ SSA_NAME_VERSION (gimple_phi_result (phi))))
{
/* Skip unprocessed phis. */
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "[BACKEDGE] ");
print_generic_expr (dump_file, var);
fprintf (dump_file, " in ");
- print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
+ print_gimple_stmt (dump_file, phi, 0, TDF_SLIM);
}
}
else
process_use (stmt, var, &subinfo);
*info &= subinfo;
if (!info->is_useful ())
- {
- BREAK_FROM_IMM_USE_STMT (iter);
- return false;
- }
+ return false;
}
}
return true;
}
for (gphi_iterator gpi = gsi_start_phis (bb); !gsi_end_p (gpi);
gsi_next (&gpi))
- process_var (gimple_phi_result (gpi.phi ()));
+ {
+ tree result = gimple_phi_result (gpi.phi ());
+ process_var (result);
+ bitmap_set_bit (m_visited_phis, SSA_NAME_VERSION (result));
+ }
+ bitmap_clear (m_visited_phis);
}
/* Delete the definition of VAR, which has no uses. */
switch (gimple_assign_rhs_code (assign))
{
case ABS_EXPR:
+ case ABSU_EXPR:
case NEGATE_EXPR:
return gimple_assign_rhs1 (assign);
void
backprop::prepare_change (tree var)
{
- if (MAY_HAVE_DEBUG_STMTS)
+ if (MAY_HAVE_DEBUG_BIND_STMTS)
insert_debug_temp_for_var_def (NULL, var);
reset_flow_sensitive_info (var);
}