+2019-08-05 Richard Sandiford <richard.sandiford@arm.com>
+
+ * gimple.h (gimple_move_vops): Declare.
+ * gimple.c (gimple_move_vops): New function
+ * gimple-fold.c (replace_call_with_call_and_fold)
+ (gimple_fold_builtin_memory_op, gimple_fold_builtin_memset)
+ (gimple_fold_builtin_stpcpy, fold_builtin_atomic_compare_exchange)
+ (gimple_fold_call): Use it.
+ * ipa-param-manipulation.c (ipa_modify_call_arguments): Likewise.
+ * tree-call-cdce.c (use_internal_fn): Likewise.
+ * tree-if-conv.c (predicate_load_or_store): Likewise.
+ * tree-ssa-ccp.c (optimize_atomic_bit_test_and): Likewise.
+ * tree-ssa-math-opts.c (pass_cse_reciprocals::execute): Likewise.
+ * tree-ssa-propagate.c (finish_update_gimple_call): Likewise.
+ (update_call_from_tree): Likewise.
+ * tree-vect-stmts.c (vectorizable_load): Likewise.
+ * tree-vectorizer.c (adjust_simduid_builtins): Likewise.
+
2019-08-05 Martin Liska <mliska@suse.cz>
PR c++/91334
gimple *stmt = gsi_stmt (*gsi);
gimple_call_set_lhs (repl, gimple_call_lhs (stmt));
gimple_set_location (repl, gimple_location (stmt));
- if (gimple_vdef (stmt)
- && TREE_CODE (gimple_vdef (stmt)) == SSA_NAME)
- {
- gimple_set_vdef (repl, gimple_vdef (stmt));
- SSA_NAME_DEF_STMT (gimple_vdef (repl)) = repl;
- }
- if (gimple_vuse (stmt))
- gimple_set_vuse (repl, gimple_vuse (stmt));
+ gimple_move_vops (repl, stmt);
gsi_replace (gsi, repl, false);
fold_stmt (gsi);
}
= gimple_build_assign (fold_build2 (MEM_REF, desttype,
dest, off0),
srcmem);
- gimple_set_vuse (new_stmt, gimple_vuse (stmt));
- gimple_set_vdef (new_stmt, gimple_vdef (stmt));
- if (gimple_vdef (new_stmt)
- && TREE_CODE (gimple_vdef (new_stmt)) == SSA_NAME)
- SSA_NAME_DEF_STMT (gimple_vdef (new_stmt)) = new_stmt;
+ gimple_move_vops (new_stmt, stmt);
if (!lhs)
{
gsi_replace (gsi, new_stmt, false);
= gimple_build_assign (fold_build2 (MEM_REF, desttype, dest, off0),
fold_build2 (MEM_REF, srctype, src, off0));
set_vop_and_replace:
- gimple_set_vuse (new_stmt, gimple_vuse (stmt));
- gimple_set_vdef (new_stmt, gimple_vdef (stmt));
- if (gimple_vdef (new_stmt)
- && TREE_CODE (gimple_vdef (new_stmt)) == SSA_NAME)
- SSA_NAME_DEF_STMT (gimple_vdef (new_stmt)) = new_stmt;
+ gimple_move_vops (new_stmt, stmt);
if (!lhs)
{
gsi_replace (gsi, new_stmt, false);
var = fold_build2 (MEM_REF, etype, dest, build_int_cst (ptr_type_node, 0));
gimple *store = gimple_build_assign (var, build_int_cst_type (etype, cval));
- gimple_set_vuse (store, gimple_vuse (stmt));
- tree vdef = gimple_vdef (stmt);
- if (vdef && TREE_CODE (vdef) == SSA_NAME)
- {
- gimple_set_vdef (store, gimple_vdef (stmt));
- SSA_NAME_DEF_STMT (gimple_vdef (stmt)) = store;
- }
+ gimple_move_vops (store, stmt);
gsi_insert_before (gsi, store, GSI_SAME_STMT);
if (gimple_call_lhs (stmt))
{
tem, build_int_cst (size_type_node, 1));
gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
gcall *repl = gimple_build_call (fn, 3, dest, src, lenp1);
- gimple_set_vuse (repl, gimple_vuse (stmt));
- gimple_set_vdef (repl, gimple_vdef (stmt));
- if (gimple_vdef (repl)
- && TREE_CODE (gimple_vdef (repl)) == SSA_NAME)
- SSA_NAME_DEF_STMT (gimple_vdef (repl)) = repl;
+ gimple_move_vops (repl, stmt);
gsi_insert_before (gsi, repl, GSI_SAME_STMT);
/* Replace the result with dest + len. */
stmts = NULL;
gimple_call_arg (stmt, 5));
tree lhs = make_ssa_name (ctype);
gimple_call_set_lhs (g, lhs);
- gimple_set_vdef (g, gimple_vdef (stmt));
- gimple_set_vuse (g, gimple_vuse (stmt));
- SSA_NAME_DEF_STMT (gimple_vdef (g)) = g;
+ gimple_move_vops (g, stmt);
tree oldlhs = gimple_call_lhs (stmt);
if (stmt_can_throw_internal (cfun, stmt))
{
SSA_NAME_DEF_STMT (lhs) = gimple_build_nop ();
set_ssa_default_def (cfun, var, lhs);
}
- gimple_set_vuse (new_stmt, gimple_vuse (stmt));
- gimple_set_vdef (new_stmt, gimple_vdef (stmt));
+ gimple_move_vops (new_stmt, stmt);
gsi_replace (gsi, new_stmt, false);
return true;
}
return copy;
}
+/* Move OLD_STMT's vuse and vdef operands to NEW_STMT, on the assumption
+ that OLD_STMT is about to be removed. */
+
+void
+gimple_move_vops (gimple *new_stmt, gimple *old_stmt)
+{
+ tree vdef = gimple_vdef (old_stmt);
+ gimple_set_vuse (new_stmt, gimple_vuse (old_stmt));
+ gimple_set_vdef (new_stmt, vdef);
+ if (vdef && TREE_CODE (vdef) == SSA_NAME)
+ SSA_NAME_DEF_STMT (vdef) = new_stmt;
+}
/* Return true if statement S has side-effects. We consider a
statement to have side effects if:
tree gimple_get_lhs (const gimple *);
void gimple_set_lhs (gimple *, tree);
gimple *gimple_copy (gimple *);
+void gimple_move_vops (gimple *, gimple *);
bool gimple_has_side_effects (const gimple *);
bool gimple_could_trap_p_1 (gimple *, bool, bool);
bool gimple_could_trap_p (gimple *);
gimple_call_set_chain (new_stmt, gimple_call_chain (stmt));
gimple_call_copy_flags (new_stmt, stmt);
if (gimple_in_ssa_p (cfun))
- {
- gimple_set_vuse (new_stmt, gimple_vuse (stmt));
- if (gimple_vdef (stmt))
- {
- gimple_set_vdef (new_stmt, gimple_vdef (stmt));
- SSA_NAME_DEF_STMT (gimple_vdef (new_stmt)) = new_stmt;
- }
- }
+ gimple_move_vops (new_stmt, stmt);
if (dump_file && (dump_flags & TDF_DETAILS))
{
{
gimple_stmt_iterator gsi = gsi_for_stmt (call);
gcall *new_call = gimple_build_call_internal (IFN_SET_EDOM, 0);
- gimple_set_vuse (new_call, gimple_vuse (call));
- gimple_set_vdef (new_call, gimple_vdef (call));
- SSA_NAME_DEF_STMT (gimple_vdef (new_call)) = new_call;
+ gimple_move_vops (new_call, call);
gimple_set_location (new_call, gimple_location (call));
gsi_replace (&gsi, new_call, false);
call = new_call;
new_stmt
= gimple_build_call_internal (IFN_MASK_STORE, 4, addr, ptr,
mask, rhs);
- gimple_set_vuse (new_stmt, gimple_vuse (stmt));
- gimple_set_vdef (new_stmt, gimple_vdef (stmt));
- SSA_NAME_DEF_STMT (gimple_vdef (new_stmt)) = new_stmt;
+ gimple_move_vops (new_stmt, stmt);
}
gimple_call_set_nothrow (new_stmt, true);
return new_stmt;
bit, flag);
gimple_call_set_lhs (g, new_lhs);
gimple_set_location (g, gimple_location (call));
- gimple_set_vuse (g, gimple_vuse (call));
- gimple_set_vdef (g, gimple_vdef (call));
+ gimple_move_vops (g, call);
bool throws = stmt_can_throw_internal (cfun, call);
gimple_call_set_nothrow (as_a <gcall *> (g),
gimple_call_nothrow_p (as_a <gcall *> (call)));
- SSA_NAME_DEF_STMT (gimple_vdef (call)) = g;
gimple_stmt_iterator gsi = *gsip;
gsi_insert_after (&gsi, g, GSI_NEW_STMT);
edge e = NULL;
else
stmt2 = gimple_build_call_internal_vec (ifn, args);
gimple_call_set_lhs (stmt2, arg1);
- if (gimple_vdef (call))
- {
- gimple_set_vdef (stmt2, gimple_vdef (call));
- SSA_NAME_DEF_STMT (gimple_vdef (stmt2)) = stmt2;
- }
+ gimple_move_vops (stmt2, call);
gimple_call_set_nothrow (stmt2,
gimple_call_nothrow_p (call));
- gimple_set_vuse (stmt2, gimple_vuse (call));
gimple_stmt_iterator gsi2 = gsi_for_stmt (call);
gsi_replace (&gsi2, stmt2, true);
}
{
gimple_call_set_lhs (new_stmt, gimple_call_lhs (stmt));
move_ssa_defining_stmt_for_defs (new_stmt, stmt);
- gimple_set_vuse (new_stmt, gimple_vuse (stmt));
- gimple_set_vdef (new_stmt, gimple_vdef (stmt));
+ gimple_move_vops (new_stmt, stmt);
gimple_set_location (new_stmt, gimple_location (stmt));
if (gimple_block (new_stmt) == NULL_TREE)
gimple_set_block (new_stmt, gimple_block (stmt));
STRIP_USELESS_TYPE_CONVERSION (expr);
new_stmt = gimple_build_assign (lhs, expr);
move_ssa_defining_stmt_for_defs (new_stmt, stmt);
- gimple_set_vuse (new_stmt, gimple_vuse (stmt));
- gimple_set_vdef (new_stmt, gimple_vdef (stmt));
+ gimple_move_vops (new_stmt, stmt);
}
else if (!TREE_SIDE_EFFECTS (expr))
{
else
lhs = create_tmp_var (TREE_TYPE (expr));
new_stmt = gimple_build_assign (lhs, expr);
- gimple_set_vuse (new_stmt, gimple_vuse (stmt));
- gimple_set_vdef (new_stmt, gimple_vdef (stmt));
+ gimple_move_vops (new_stmt, stmt);
move_ssa_defining_stmt_for_defs (new_stmt, stmt);
}
gimple_set_location (new_stmt, gimple_location (stmt));
new_stmt = gimple_build_assign (vec_dest, data_ref);
new_temp = make_ssa_name (vec_dest, new_stmt);
gimple_assign_set_lhs (new_stmt, new_temp);
- gimple_set_vdef (new_stmt, gimple_vdef (stmt_info->stmt));
- gimple_set_vuse (new_stmt, gimple_vuse (stmt_info->stmt));
+ gimple_move_vops (new_stmt, stmt_info->stmt);
vect_finish_stmt_generation (stmt_info, new_stmt, gsi);
msq = new_temp;
: BUILT_IN_GOMP_ORDERED_END);
gimple *g
= gimple_build_call (builtin_decl_explicit (bcode), 0);
- tree vdef = gimple_vdef (stmt);
- gimple_set_vdef (g, vdef);
- SSA_NAME_DEF_STMT (vdef) = g;
- gimple_set_vuse (g, gimple_vuse (stmt));
+ gimple_move_vops (g, stmt);
gsi_replace (&i, g, true);
continue;
}