summaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-06-25 12:35:21 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-06-25 12:35:21 +0000
commitbb0d250905bbcdd1586f99dc4d9fc682353d4ca6 (patch)
tree2611724ce72ecc8b57a3170f0e0549f24c664069 /gcc/tree-vect-loop.c
parent2f6c1cf468cbc75b2a1fb914e6b7d00633484756 (diff)
downloadgcc-bb0d250905bbcdd1586f99dc4d9fc682353d4ca6.tar.gz
PR tree-optimization/57705
* tree-vect-loop.c (vect_is_simple_iv_evolution): Allow SSA_NAME step, provided that it is not defined inside the loop. (vect_analyze_scalar_cycles_1): Disallow SSA_NAME step in nested loop. (get_initial_def_for_induction): Handle SSA_NAME IV step. * gcc.dg/vect/pr57705.c: New test. * gcc.dg/vect/vect-iv-7.c: Add noclone attribute, remove xfail. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200394 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r--gcc/tree-vect-loop.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 3b10b1989b4..c9b10213257 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -500,7 +500,7 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
/* Function vect_is_simple_iv_evolution.
FORNOW: A simple evolution of an induction variables in the loop is
- considered a polynomial evolution with constant step. */
+ considered a polynomial evolution. */
static bool
vect_is_simple_iv_evolution (unsigned loop_nb, tree access_fn, tree * init,
@@ -509,6 +509,7 @@ vect_is_simple_iv_evolution (unsigned loop_nb, tree access_fn, tree * init,
tree init_expr;
tree step_expr;
tree evolution_part = evolution_part_in_loop_num (access_fn, loop_nb);
+ basic_block bb;
/* When there is no evolution in this loop, the evolution function
is not "simple". */
@@ -534,7 +535,10 @@ vect_is_simple_iv_evolution (unsigned loop_nb, tree access_fn, tree * init,
*init = init_expr;
*step = step_expr;
- if (TREE_CODE (step_expr) != INTEGER_CST)
+ if (TREE_CODE (step_expr) != INTEGER_CST
+ && (TREE_CODE (step_expr) != SSA_NAME
+ || ((bb = gimple_bb (SSA_NAME_DEF_STMT (step_expr)))
+ && flow_bb_inside_loop_p (get_loop (cfun, loop_nb), bb))))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -556,7 +560,7 @@ static void
vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
{
basic_block bb = loop->header;
- tree dumy;
+ tree init, step;
vec<gimple> worklist;
worklist.create (64);
gimple_stmt_iterator gsi;
@@ -605,7 +609,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
}
if (!access_fn
- || !vect_is_simple_iv_evolution (loop->num, access_fn, &dumy, &dumy))
+ || !vect_is_simple_iv_evolution (loop->num, access_fn, &init, &step)
+ || (LOOP_VINFO_LOOP (loop_vinfo) != loop
+ && TREE_CODE (step) != INTEGER_CST))
{
worklist.safe_push (phi);
continue;
@@ -3273,10 +3279,14 @@ get_initial_def_for_induction (gimple iv_phi)
expr = build_int_cst (TREE_TYPE (step_expr), vf);
new_name = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),
expr, step_expr);
+ if (TREE_CODE (step_expr) == SSA_NAME)
+ new_name = vect_init_vector (iv_phi, new_name,
+ TREE_TYPE (step_expr), NULL);
}
t = unshare_expr (new_name);
- gcc_assert (CONSTANT_CLASS_P (new_name));
+ gcc_assert (CONSTANT_CLASS_P (new_name)
+ || TREE_CODE (new_name) == SSA_NAME);
stepvectype = get_vectype_for_scalar_type (TREE_TYPE (new_name));
gcc_assert (stepvectype);
new_vec = build_vector_from_val (stepvectype, t);
@@ -3332,8 +3342,12 @@ get_initial_def_for_induction (gimple iv_phi)
expr = build_int_cst (TREE_TYPE (step_expr), nunits);
new_name = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),
expr, step_expr);
+ if (TREE_CODE (step_expr) == SSA_NAME)
+ new_name = vect_init_vector (iv_phi, new_name,
+ TREE_TYPE (step_expr), NULL);
t = unshare_expr (new_name);
- gcc_assert (CONSTANT_CLASS_P (new_name));
+ gcc_assert (CONSTANT_CLASS_P (new_name)
+ || TREE_CODE (new_name) == SSA_NAME);
new_vec = build_vector_from_val (stepvectype, t);
vec_step = vect_init_vector (iv_phi, new_vec, stepvectype, NULL);