The following makes sure to convert an induction step to the vector
component type from, for example _BitInt, before using it.
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
PR tree-optimization/123771
* tree-vect-loop.cc (vectorizable_induction): Convert step
also for VLA vectors.
---
gcc/tree-vect-loop.cc | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 61f5936b4eb..e30b8e6ef56 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -9835,14 +9835,15 @@ vectorizable_induction (loop_vec_info loop_vinfo,
}
else
{
+ tree step = gimple_convert (&init_stmts, stept, steps[0]);
if (init_node)
;
- else if (INTEGRAL_TYPE_P (TREE_TYPE (steps[0])))
+ else if (INTEGRAL_TYPE_P (stept))
{
new_name = gimple_convert (&init_stmts, stept, inits[0]);
/* Build the initial value directly as a VEC_SERIES_EXPR. */
vec_init = gimple_build (&init_stmts, VEC_SERIES_EXPR,
- step_vectype, new_name, steps[0]);
+ step_vectype, new_name, step);
if (!useless_type_conversion_p (vectype, step_vectype))
vec_init = gimple_build (&init_stmts, VIEW_CONVERT_EXPR,
vectype, vec_init);
@@ -9852,19 +9853,18 @@ vectorizable_induction (loop_vec_info loop_vinfo,
/* Build:
[base, base, base, ...]
+ (vectype) [0, 1, 2, ...] * [step, step, step, ...]. */
- gcc_assert (SCALAR_FLOAT_TYPE_P (TREE_TYPE (steps[0])));
+ gcc_assert (SCALAR_FLOAT_TYPE_P (stept));
gcc_assert (flag_associative_math);
gcc_assert (index_vectype != NULL_TREE);
tree index = build_index_vector (index_vectype, 0, 1);
- new_name = gimple_convert (&init_stmts, TREE_TYPE (steps[0]),
- inits[0]);
+ new_name = gimple_convert (&init_stmts, stept, inits[0]);
tree base_vec = gimple_build_vector_from_val (&init_stmts,
step_vectype,
new_name);
tree step_vec = gimple_build_vector_from_val (&init_stmts,
step_vectype,
- steps[0]);
+ step);
vec_init = gimple_build (&init_stmts, FLOAT_EXPR,
step_vectype, index);
vec_init = gimple_build (&init_stmts, MULT_EXPR,
@@ -9877,7 +9877,7 @@ vectorizable_induction (loop_vec_info loop_vinfo,
}
/* iv_loop is nested in the loop to be vectorized. Generate:
vec_step = [S, S, S, S] */
- t = unshare_expr (steps[0]);
+ t = unshare_expr (step);
gcc_assert (CONSTANT_CLASS_P (t)
|| TREE_CODE (t) == SSA_NAME);
vec_step = gimple_build_vector_from_val (&init_stmts,
--
2.51.0