From: Richard Biener Date: Thu, 15 Oct 2015 11:39:09 +0000 (+0000) Subject: tree-vectorizer.h (vect_get_new_ssa_name): Declare. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0e22bb5ad3e0a5e08090487cec3ba8413f516a29;p=gcc.git tree-vectorizer.h (vect_get_new_ssa_name): Declare. 2015-10-15 Richard Biener * tree-vectorizer.h (vect_get_new_ssa_name): Declare. * tree-vect-data-refs.c (vect_get_new_ssa_name): New helper. * tree-vect-loop.c (get_initial_def_for_induction): Drop use of force_gimple_operand in favor of gimple_build. Use vect_get_new_ssa_name. * tree-vect-stmts.c (vect_init_vector): Use vect_get_new_ssa_name. (vectorizable_mask_load_store): Likewise. (vectorizable_call): Likewise. (vectorizable_store): Likewise. (vectorizable_load): Likewise. (vect_get_vec_def_for_stmt_copy): Remove redundant stmt. From-SVN: r228841 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 75c4c17dd35..9e153a84e87 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2015-10-15 Richard Biener + + * tree-vectorizer.h (vect_get_new_ssa_name): Declare. + * tree-vect-data-refs.c (vect_get_new_ssa_name): New helper. + * tree-vect-loop.c (get_initial_def_for_induction): Drop + use of force_gimple_operand in favor of gimple_build. + Use vect_get_new_ssa_name. + * tree-vect-stmts.c (vect_init_vector): Use vect_get_new_ssa_name. + (vectorizable_mask_load_store): Likewise. + (vectorizable_call): Likewise. + (vectorizable_store): Likewise. + (vectorizable_load): Likewise. + (vect_get_vec_def_for_stmt_copy): Remove redundant stmt. + 2015-10-15 Richard Sandiford PR tree-optimization/67945 diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index c3db22fa87f..755b5a17e50 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -3897,6 +3897,41 @@ vect_get_new_vect_var (tree type, enum vect_var_kind var_kind, const char *name) return new_vect_var; } +/* Like vect_get_new_vect_var but return an SSA name. */ + +tree +vect_get_new_ssa_name (tree type, enum vect_var_kind var_kind, const char *name) +{ + const char *prefix; + tree new_vect_var; + + switch (var_kind) + { + case vect_simple_var: + prefix = "vect"; + break; + case vect_scalar_var: + prefix = "stmp"; + break; + case vect_pointer_var: + prefix = "vectp"; + break; + default: + gcc_unreachable (); + } + + if (name) + { + char* tmp = concat (prefix, "_", name, NULL); + new_vect_var = make_temp_ssa_name (type, NULL, tmp); + free (tmp); + } + else + new_vect_var = make_temp_ssa_name (type, NULL, prefix); + + return new_vect_var; +} + /* Duplicate ptr info and set alignment/misaligment on NAME from DR. */ static void diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 9285e516b46..32c54a78d88 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-scalar-evolution.h" #include "tree-vectorizer.h" #include "target.h" +#include "gimple-fold.h" /* Loop Vectorization Pass. @@ -3341,9 +3342,8 @@ get_initial_def_for_induction (gimple *iv_phi) struct loop *iv_loop; basic_block new_bb; tree new_vec, vec_init, vec_step, t; - tree new_var; tree new_name; - gimple *init_stmt, *new_stmt; + gimple *new_stmt; gphi *induction_phi; tree induc_def, vec_def, vec_dest; tree init_expr, step_expr; @@ -3353,7 +3353,7 @@ get_initial_def_for_induction (gimple *iv_phi) tree expr; stmt_vec_info phi_info = vinfo_for_stmt (iv_phi); bool nested_in_vect_loop = false; - gimple_seq stmts = NULL; + gimple_seq stmts; imm_use_iterator imm_iter; use_operand_p use_p; gimple *exit_phi; @@ -3394,9 +3394,8 @@ get_initial_def_for_induction (gimple *iv_phi) gcc_assert (ncopies >= 1); /* Convert the step to the desired type. */ - step_expr = force_gimple_operand (fold_convert (TREE_TYPE (vectype), - step_expr), - &stmts, true, NULL_TREE); + stmts = NULL; + step_expr = gimple_convert (&stmts, TREE_TYPE (vectype), step_expr); if (stmts) { new_bb = gsi_insert_seq_on_edge_immediate (pe, stmts); @@ -3417,14 +3416,13 @@ get_initial_def_for_induction (gimple *iv_phi) if (!useless_type_conversion_p (vectype, TREE_TYPE (vec_init))) { new_stmt - = gimple_build_assign (vect_get_new_vect_var (vectype, + = gimple_build_assign (vect_get_new_ssa_name (vectype, vect_simple_var, "vec_iv_"), VIEW_CONVERT_EXPR, build1 (VIEW_CONVERT_EXPR, vectype, vec_init)); - vec_init = make_ssa_name (gimple_assign_lhs (new_stmt), new_stmt); - gimple_assign_set_lhs (new_stmt, vec_init); + vec_init = gimple_assign_lhs (new_stmt); new_bb = gsi_insert_on_edge_immediate (loop_preheader_edge (iv_loop), new_stmt); gcc_assert (!new_bb); @@ -3438,16 +3436,8 @@ get_initial_def_for_induction (gimple *iv_phi) /* iv_loop is the loop to be vectorized. Create: vec_init = [X, X+S, X+2*S, X+3*S] (S = step_expr, X = init_expr) */ - new_var = vect_get_new_vect_var (TREE_TYPE (vectype), - vect_scalar_var, "var_"); - new_name = force_gimple_operand (fold_convert (TREE_TYPE (vectype), - init_expr), - &stmts, false, new_var); - if (stmts) - { - new_bb = gsi_insert_seq_on_edge_immediate (pe, stmts); - gcc_assert (!new_bb); - } + stmts = NULL; + new_name = gimple_convert (&stmts, TREE_TYPE (vectype), init_expr); vec_alloc (v, nunits); bool constant_p = is_gimple_min_invariant (new_name); @@ -3455,26 +3445,18 @@ get_initial_def_for_induction (gimple *iv_phi) for (i = 1; i < nunits; i++) { /* Create: new_name_i = new_name + step_expr */ - new_name = fold_build2 (PLUS_EXPR, TREE_TYPE (new_name), - new_name, step_expr); + new_name = gimple_build (&stmts, PLUS_EXPR, TREE_TYPE (new_name), + new_name, step_expr); if (!is_gimple_min_invariant (new_name)) - { - init_stmt = gimple_build_assign (new_var, new_name); - new_name = make_ssa_name (new_var, init_stmt); - gimple_assign_set_lhs (init_stmt, new_name); - new_bb = gsi_insert_on_edge_immediate (pe, init_stmt); - gcc_assert (!new_bb); - if (dump_enabled_p ()) - { - dump_printf_loc (MSG_NOTE, vect_location, - "created new init_stmt: "); - dump_gimple_stmt (MSG_NOTE, TDF_SLIM, init_stmt, 0); - dump_printf (MSG_NOTE, "\n"); - } - constant_p = false; - } + constant_p = false; CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, new_name); } + if (stmts) + { + new_bb = gsi_insert_seq_on_edge_immediate (pe, stmts); + gcc_assert (!new_bb); + } + /* Create a vector from [new_name_0, new_name_1, ..., new_name_nunits-1] */ if (constant_p) new_vec = build_vector_from_ctor (vectype, v); diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 4f5895c195b..1386dc05549 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -1319,13 +1319,10 @@ vect_init_vector (gimple *stmt, tree val, tree type, gimple_stmt_iterator *gsi) val = build_vector_from_val (type, val); } - new_var = vect_get_new_vect_var (type, vect_simple_var, "cst_"); - init_stmt = gimple_build_assign (new_var, val); - new_temp = make_ssa_name (new_var, init_stmt); - gimple_assign_set_lhs (init_stmt, new_temp); + new_temp = vect_get_new_ssa_name (type, vect_simple_var, "cst_"); + init_stmt = gimple_build_assign (new_temp, val); vect_init_vector_1 (stmt, init_stmt, gsi); - vec_oprnd = gimple_assign_lhs (init_stmt); - return vec_oprnd; + return new_temp; } @@ -1509,7 +1506,6 @@ vect_get_vec_def_for_stmt_copy (enum vect_def_type dt, tree vec_oprnd) gcc_assert (def_stmt_info); vec_stmt_for_operand = STMT_VINFO_RELATED_STMT (def_stmt_info); gcc_assert (vec_stmt_for_operand); - vec_oprnd = gimple_get_lhs (vec_stmt_for_operand); if (gimple_code (vec_stmt_for_operand) == GIMPLE_PHI) vec_oprnd = PHI_RESULT (vec_stmt_for_operand); else @@ -1888,8 +1884,7 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, { gcc_assert (TYPE_VECTOR_SUBPARTS (TREE_TYPE (op)) == TYPE_VECTOR_SUBPARTS (idxtype)); - var = vect_get_new_vect_var (idxtype, vect_simple_var, NULL); - var = make_ssa_name (var); + var = vect_get_new_ssa_name (idxtype, vect_simple_var); op = build1 (VIEW_CONVERT_EXPR, idxtype, op); new_stmt = gimple_build_assign (var, VIEW_CONVERT_EXPR, op); @@ -1915,9 +1910,7 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, { gcc_assert (TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask_op)) == TYPE_VECTOR_SUBPARTS (masktype)); - var = vect_get_new_vect_var (masktype, vect_simple_var, - NULL); - var = make_ssa_name (var); + var = vect_get_new_ssa_name (masktype, vect_simple_var); mask_op = build1 (VIEW_CONVERT_EXPR, masktype, mask_op); new_stmt = gimple_build_assign (var, VIEW_CONVERT_EXPR, mask_op); @@ -1934,8 +1927,7 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, { gcc_assert (TYPE_VECTOR_SUBPARTS (vectype) == TYPE_VECTOR_SUBPARTS (rettype)); - var = vect_get_new_vect_var (rettype, vect_simple_var, NULL); - op = make_ssa_name (var, new_stmt); + op = vect_get_new_ssa_name (rettype, vect_simple_var); gimple_call_set_lhs (new_stmt, op); vect_finish_stmt_generation (stmt, new_stmt, gsi); var = make_ssa_name (vec_dest); @@ -2379,14 +2371,11 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt, v[k] = build_int_cst (unsigned_type_node, j * nunits_out + k); tree cst = build_vector (vectype_out, v); tree new_var - = vect_get_new_vect_var (vectype_out, vect_simple_var, "cst_"); + = vect_get_new_ssa_name (vectype_out, vect_simple_var, "cst_"); gimple *init_stmt = gimple_build_assign (new_var, cst); - new_temp = make_ssa_name (new_var, init_stmt); - gimple_assign_set_lhs (init_stmt, new_temp); vect_init_vector_1 (stmt, init_stmt, NULL); new_temp = make_ssa_name (vec_dest); - new_stmt = gimple_build_assign (new_temp, - gimple_assign_lhs (init_stmt)); + new_stmt = gimple_build_assign (new_temp, new_var); } else { @@ -5350,8 +5339,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, { gcc_assert (TYPE_VECTOR_SUBPARTS (TREE_TYPE (src)) == TYPE_VECTOR_SUBPARTS (srctype)); - var = vect_get_new_vect_var (srctype, vect_simple_var, NULL); - var = make_ssa_name (var); + var = vect_get_new_ssa_name (srctype, vect_simple_var); src = build1 (VIEW_CONVERT_EXPR, srctype, src); new_stmt = gimple_build_assign (var, VIEW_CONVERT_EXPR, src); vect_finish_stmt_generation (stmt, new_stmt, gsi); @@ -5362,8 +5350,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, { gcc_assert (TYPE_VECTOR_SUBPARTS (TREE_TYPE (op)) == TYPE_VECTOR_SUBPARTS (idxtype)); - var = vect_get_new_vect_var (idxtype, vect_simple_var, NULL); - var = make_ssa_name (var); + var = vect_get_new_ssa_name (idxtype, vect_simple_var); op = build1 (VIEW_CONVERT_EXPR, idxtype, op); new_stmt = gimple_build_assign (var, VIEW_CONVERT_EXPR, op); vect_finish_stmt_generation (stmt, new_stmt, gsi); @@ -6408,8 +6395,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, { gcc_assert (TYPE_VECTOR_SUBPARTS (TREE_TYPE (op)) == TYPE_VECTOR_SUBPARTS (idxtype)); - var = vect_get_new_vect_var (idxtype, vect_simple_var, NULL); - var = make_ssa_name (var); + var = vect_get_new_ssa_name (idxtype, vect_simple_var); op = build1 (VIEW_CONVERT_EXPR, idxtype, op); new_stmt = gimple_build_assign (var, VIEW_CONVERT_EXPR, op); @@ -6424,8 +6410,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, { gcc_assert (TYPE_VECTOR_SUBPARTS (vectype) == TYPE_VECTOR_SUBPARTS (rettype)); - var = vect_get_new_vect_var (rettype, vect_simple_var, NULL); - op = make_ssa_name (var, new_stmt); + op = vect_get_new_ssa_name (rettype, vect_simple_var); gimple_call_set_lhs (new_stmt, op); vect_finish_stmt_generation (stmt, new_stmt, gsi); var = make_ssa_name (vec_dest); diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index aca3ccc286a..bdd8e6aec32 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1020,6 +1020,8 @@ extern void vect_transform_grouped_load (gimple *, vec , int, gimple_stmt_iterator *); extern void vect_record_grouped_load_vectors (gimple *, vec ); extern tree vect_get_new_vect_var (tree, enum vect_var_kind, const char *); +extern tree vect_get_new_ssa_name (tree, enum vect_var_kind, + const char * = NULL); extern tree vect_create_addr_base_for_vector_ref (gimple *, gimple_seq *, tree, struct loop *, tree = NULL_TREE);