aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop-manip.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2012-03-23 11:34:32 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2012-03-23 11:34:32 +0000
commit0ac168a1cd87bfefee6f8ebad245080cfe16fc1d (patch)
tree8b6ebe34884569f079b8d732cd6e253f6ca11fac /gcc/tree-vect-loop-manip.c
parent6e349de504c00b9451becd66103ae96eb4b6ad56 (diff)
downloadgcc-0ac168a1cd87bfefee6f8ebad245080cfe16fc1d.zip
gcc-0ac168a1cd87bfefee6f8ebad245080cfe16fc1d.tar.gz
gcc-0ac168a1cd87bfefee6f8ebad245080cfe16fc1d.tar.bz2
re PR tree-optimization/52678 (internal compiler error: in vect_update_ivs_after_vectorizer, at tree-vect-loop-manip.c:1842)
2012-03-23 Richard Guenther <rguenther@suse.de> PR tree-optimization/52678 * tree-vectorizer.h (struct _stmt_vec_info): Add loop_phi_evolution_part member. (STMT_VINFO_LOOP_PHI_EVOLUTION_PART): New define. * tree-vect-loop.c (vect_analyze_scalar_cycles_1): Initialize STMT_VINFO_LOOP_PHI_EVOLUTION_PART. * tree-vect-loop-manip.c (vect_update_ivs_after_vectorizer): Use the cached evolution part and the PHI nodes value from the loop preheader edge instead of re-analyzing the evolution. * gfortran.dg/pr52678.f: New testcase. From-SVN: r185734
Diffstat (limited to 'gcc/tree-vect-loop-manip.c')
-rw-r--r--gcc/tree-vect-loop-manip.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 8cf1825..499dece 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -1797,13 +1797,12 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
!gsi_end_p (gsi) && !gsi_end_p (gsi1);
gsi_next (&gsi), gsi_next (&gsi1))
{
- tree access_fn = NULL;
- tree evolution_part;
tree init_expr;
tree step_expr, off;
tree type;
tree var, ni, ni_name;
gimple_stmt_iterator last_gsi;
+ stmt_vec_info stmt_info;
phi = gsi_stmt (gsi);
phi1 = gsi_stmt (gsi1);
@@ -1822,45 +1821,34 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
}
/* Skip reduction phis. */
- if (STMT_VINFO_DEF_TYPE (vinfo_for_stmt (phi)) == vect_reduction_def)
+ stmt_info = vinfo_for_stmt (phi);
+ if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def)
{
if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "reduc phi. skip.");
continue;
}
- access_fn = analyze_scalar_evolution (loop, PHI_RESULT (phi));
- gcc_assert (access_fn);
- /* We can end up with an access_fn like
- (short int) {(short unsigned int) i_49, +, 1}_1
- for further analysis we need to strip the outer cast but we
- need to preserve the original type. */
- type = TREE_TYPE (access_fn);
- STRIP_NOPS (access_fn);
- evolution_part =
- unshare_expr (evolution_part_in_loop_num (access_fn, loop->num));
- gcc_assert (evolution_part != NULL_TREE);
+ type = TREE_TYPE (gimple_phi_result (phi));
+ step_expr = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_info);
+ step_expr = unshare_expr (step_expr);
/* FORNOW: We do not support IVs whose evolution function is a polynomial
of degree >= 2 or exponential. */
- gcc_assert (!tree_is_chrec (evolution_part));
+ gcc_assert (!tree_is_chrec (step_expr));
- step_expr = evolution_part;
- init_expr = unshare_expr (initial_condition_in_loop_num (access_fn,
- loop->num));
- init_expr = fold_convert (type, init_expr);
+ init_expr = PHI_ARG_DEF_FROM_EDGE (phi, loop_preheader_edge (loop));
off = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),
fold_convert (TREE_TYPE (step_expr), niters),
step_expr);
- if (POINTER_TYPE_P (TREE_TYPE (init_expr)))
+ if (POINTER_TYPE_P (type))
ni = fold_build_pointer_plus (init_expr, off);
else
- ni = fold_build2 (PLUS_EXPR, TREE_TYPE (init_expr),
- init_expr,
- fold_convert (TREE_TYPE (init_expr), off));
+ ni = fold_build2 (PLUS_EXPR, type,
+ init_expr, fold_convert (type, off));
- var = create_tmp_var (TREE_TYPE (init_expr), "tmp");
+ var = create_tmp_var (type, "tmp");
add_referenced_var (var);
last_gsi = gsi_last_bb (exit_bb);