+2018-07-31 Richard Sandiford <richard.sandiford@arm.com>
+
+ * tree-vectorizer.h (vec_info::replace_stmt): Declare.
+ * tree-vectorizer.c (vec_info::replace_stmt): New function.
+ * tree-vect-slp.c (vect_remove_slp_scalar_calls): Use it.
+ * tree-vect-stmts.c (vectorizable_call): Likewise.
+ (vectorizable_simd_clone_call): Likewise.
+
2018-07-31 Richard Sandiford <richard.sandiford@arm.com>
* tree-vectorizer.h (vec_info::remove_stmt): Declare.
continue;
lhs = gimple_call_lhs (stmt);
new_stmt = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs)));
- set_vinfo_for_stmt (new_stmt, stmt_info);
- set_vinfo_for_stmt (stmt, NULL);
- STMT_VINFO_STMT (stmt_info) = new_stmt;
gsi = gsi_for_stmt (stmt);
- gsi_replace (&gsi, new_stmt, false);
+ stmt_info->vinfo->replace_stmt (&gsi, stmt_info, new_stmt);
SSA_NAME_DEF_STMT (gimple_assign_lhs (new_stmt)) = new_stmt;
}
}
gassign *new_stmt
= gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs)));
- set_vinfo_for_stmt (new_stmt, stmt_info);
- set_vinfo_for_stmt (stmt_info->stmt, NULL);
- STMT_VINFO_STMT (stmt_info) = new_stmt;
- gsi_replace (gsi, new_stmt, false);
+ vinfo->replace_stmt (gsi, stmt_info, new_stmt);
return true;
}
}
else
new_stmt = gimple_build_nop ();
- set_vinfo_for_stmt (new_stmt, stmt_info);
- set_vinfo_for_stmt (stmt, NULL);
- STMT_VINFO_STMT (stmt_info) = new_stmt;
- gsi_replace (gsi, new_stmt, true);
+ vinfo->replace_stmt (gsi, stmt_info, new_stmt);
unlink_stmt_vdef (stmt);
return true;
free_stmt_vec_info (stmt_info);
}
+/* Replace the statement at GSI by NEW_STMT, both the vectorization
+ information and the function itself. STMT_INFO describes the statement
+ at GSI. */
+
+void
+vec_info::replace_stmt (gimple_stmt_iterator *gsi, stmt_vec_info stmt_info,
+ gimple *new_stmt)
+{
+ gimple *old_stmt = stmt_info->stmt;
+ gcc_assert (!stmt_info->pattern_stmt_p && old_stmt == gsi_stmt (*gsi));
+ set_vinfo_for_stmt (old_stmt, NULL);
+ set_vinfo_for_stmt (new_stmt, stmt_info);
+ stmt_info->stmt = new_stmt;
+ gsi_replace (gsi, new_stmt, true);
+}
+
/* A helper function to free scev and LOOP niter information, as well as
clear loop constraint LOOP_C_FINITE. */
struct dr_vec_info *lookup_dr (data_reference *);
void move_dr (stmt_vec_info, stmt_vec_info);
void remove_stmt (stmt_vec_info);
+ void replace_stmt (gimple_stmt_iterator *, stmt_vec_info, gimple *);
/* The type of vectorization. */
vec_kind kind;