aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop-manip.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2009-04-16 12:44:46 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2009-04-16 12:44:46 +0000
commit550918ca7dd62e7ac5e11cce696b73fa67227639 (patch)
tree6d0cf456ca1d23a6929bcb816d7d099e283934cd /gcc/tree-vect-loop-manip.c
parente8e028cb1f56f5f7068b78ef8cab6e7ae8f211d7 (diff)
downloadgcc-550918ca7dd62e7ac5e11cce696b73fa67227639.zip
gcc-550918ca7dd62e7ac5e11cce696b73fa67227639.tar.gz
gcc-550918ca7dd62e7ac5e11cce696b73fa67227639.tar.bz2
re PR tree-optimization/39698 (wrong types for vectorized reduction)
2009-04-16 Richard Guenther <rguenther@suse.de> Ira Rosen <irar@il.ibm.com> PR tree-optimization/39698 * tree-vect-loop.c (get_initial_def_for_reduction): Use the type of the reduction variable. Only generate the def if it is needed. * omp-low.c (expand_omp_for_generic): When converting to a pointer make sure to first convert to an integer of the same precision. * tree-vect-loop-manip.c (vect_update_ivs_after_vectorizer): Retain the type of the evolution correctly in computing the new induction variable base. Co-Authored-By: Ira Rosen <irar@il.ibm.com> From-SVN: r146180
Diffstat (limited to 'gcc/tree-vect-loop-manip.c')
-rw-r--r--gcc/tree-vect-loop-manip.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index ae578f09..56f9bba 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -1593,7 +1593,8 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
tree access_fn = NULL;
tree evolution_part;
tree init_expr;
- tree step_expr;
+ tree step_expr, off;
+ tree type;
tree var, ni, ni_name;
gimple_stmt_iterator last_gsi;
@@ -1623,6 +1624,11 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
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));
@@ -1635,22 +1641,19 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
step_expr = evolution_part;
init_expr = unshare_expr (initial_condition_in_loop_num (access_fn,
loop->num));
+ init_expr = fold_convert (type, init_expr);
+ 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)))
ni = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (init_expr),
- init_expr,
- fold_build2 (MULT_EXPR, sizetype,
- fold_convert (sizetype, niters),
- step_expr));
+ init_expr,
+ fold_convert (sizetype, off));
else
ni = fold_build2 (PLUS_EXPR, TREE_TYPE (init_expr),
- fold_build2 (MULT_EXPR, TREE_TYPE (init_expr),
- fold_convert (TREE_TYPE (init_expr),
- niters),
- step_expr),
- init_expr);
-
-
+ init_expr,
+ fold_convert (TREE_TYPE (init_expr), off));
var = create_tmp_var (TREE_TYPE (init_expr), "tmp");
add_referenced_var (var);