aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2013-02-18 13:58:21 +0000
committerRichard Biener <rguenther@suse.de>2013-02-18 13:58:21 +0000
commit180c42fbf2349e9b416cb722f376fc4c82040331 (patch)
treebeccd4d1dc09cec46a171d05d656031fa88d162d /gcc/tree-vect-loop.c
parentb17a5ce5f065b223b176afe76bb49b68039b1238 (diff)
2013-02-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/56366 * tree-vect-loop.c (get_initial_def_for_induction): Properly handle sign-conversion of outer-loop initial induction value. * gcc.dg/torture/pr56366.c: New testcase. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@196121 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r--gcc/tree-vect-loop.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index d4f6bc72451..a2f90138fc9 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -3203,6 +3203,21 @@ get_initial_def_for_induction (gimple iv_phi)
tree iv_def = PHI_ARG_DEF_FROM_EDGE (iv_phi,
loop_preheader_edge (iv_loop));
vec_init = vect_get_vec_def_for_operand (iv_def, iv_phi, NULL);
+ /* If the initial value is not of proper type, convert it. */
+ if (!useless_type_conversion_p (vectype, TREE_TYPE (vec_init)))
+ {
+ new_stmt = gimple_build_assign_with_ops
+ (VIEW_CONVERT_EXPR,
+ vect_get_new_vect_var (vectype, vect_simple_var, "vec_iv_"),
+ build1 (VIEW_CONVERT_EXPR, vectype, vec_init), NULL_TREE);
+ vec_init = make_ssa_name (gimple_assign_lhs (new_stmt), new_stmt);
+ gimple_assign_set_lhs (new_stmt, vec_init);
+ new_bb = gsi_insert_on_edge_immediate (loop_preheader_edge (iv_loop),
+ new_stmt);
+ gcc_assert (!new_bb);
+ set_vinfo_for_stmt (new_stmt,
+ new_stmt_vec_info (new_stmt, loop_vinfo, NULL));
+ }
}
else
{