From: Richard Sandiford Date: Tue, 31 Jul 2018 14:26:22 +0000 (+0000) Subject: [42/46] Add vec_info::replace_stmt X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9d97912b85ac4a86767f4f1b6c47efa1ce0ba6af;p=gcc.git [42/46] Add vec_info::replace_stmt This patch adds a helper for replacing a stmt_vec_info's statement with a new statement. 2018-07-31 Richard Sandiford gcc/ * 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. From-SVN: r263157 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 396898e1ffb..bee475c5994 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2018-07-31 Richard Sandiford + + * 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 * tree-vectorizer.h (vec_info::remove_stmt): Declare. diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index fe123bf7b83..abaddd7adf4 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -4049,11 +4049,8 @@ vect_remove_slp_scalar_calls (slp_tree node) 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; } } diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 1bf9dd8116f..05f9c5cee8c 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -3634,10 +3634,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, 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; } @@ -4375,10 +4372,7 @@ vectorizable_simd_clone_call (stmt_vec_info stmt_info, } 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; diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c index abdc6cd9a76..6e647abb694 100644 --- a/gcc/tree-vectorizer.c +++ b/gcc/tree-vectorizer.c @@ -602,6 +602,22 @@ vec_info::remove_stmt (stmt_vec_info stmt_info) 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. */ diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 8aa485eb917..c7b0515284c 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -243,6 +243,7 @@ struct vec_info { 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;