Message ID | 20230626013105.18788-1-hongtao.liu@intel.com |
---|---|
State | New |
Headers | show |
Series | [1/3] Use cvt_op to save intermediate type operand instead of "subtle" vec_dest. | expand |
On Mon, 26 Jun 2023, liuhongt wrote: > When there're multiple operands in vec_oprnds0, vec_dest will be > overwrited to vectype_out, but in multi_step_cvt case, cvt_type is > expected. It caused an ICE when verify_gimple_in_cfg. > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,} and aarch64-linux-gnu. > Ok for trunk? OK. Richard. > gcc/ChangeLog: > > PR tree-optimization/110371 > PR tree-optimization/110018 > * tree-vect-stmts.cc (vectorizable_conversion): Use cvt_op to > save intermediate type operand instead of "subtle" vec_dest > for case NONE. > > gcc/testsuite/ChangeLog: > > * gcc.target/aarch64/pr110371.c: New test. > --- > gcc/testsuite/gcc.target/aarch64/pr110371.c | 20 ++++++++++++++++++++ > gcc/tree-vect-stmts.cc | 14 ++++++++++---- > 2 files changed, 30 insertions(+), 4 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/aarch64/pr110371.c > > diff --git a/gcc/testsuite/gcc.target/aarch64/pr110371.c b/gcc/testsuite/gcc.target/aarch64/pr110371.c > new file mode 100644 > index 00000000000..444e514e04f > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/pr110371.c > @@ -0,0 +1,20 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O3" } */ > + > +typedef struct dest > +{ > + double m[3][3]; > +} dest; > + > +typedef struct src > +{ > + int m[3][3]; > +} src; > + > +void > +foo (dest *a, src* s) > +{ > + for (int i = 0; i != 3; i++) > + for (int j = 0; j != 3; j++) > + a->m[i][j] = s->m[i][j]; > +} > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc > index 85d1f3ae52c..1748555a625 100644 > --- a/gcc/tree-vect-stmts.cc > +++ b/gcc/tree-vect-stmts.cc > @@ -5044,7 +5044,7 @@ vectorizable_conversion (vec_info *vinfo, > gimple **vec_stmt, slp_tree slp_node, > stmt_vector_for_cost *cost_vec) > { > - tree vec_dest; > + tree vec_dest, cvt_op = NULL_TREE; > tree scalar_dest; > tree op0, op1 = NULL_TREE; > loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo); > @@ -5568,6 +5568,13 @@ vectorizable_conversion (vec_info *vinfo, > case NONE: > vect_get_vec_defs (vinfo, stmt_info, slp_node, ncopies, > op0, &vec_oprnds0); > + /* vec_dest is intermediate type operand when multi_step_cvt. */ > + if (multi_step_cvt) > + { > + cvt_op = vec_dest; > + vec_dest = vec_dsts[0]; > + } > + > FOR_EACH_VEC_ELT (vec_oprnds0, i, vop0) > { > /* Arguments are ready, create the new vector stmt. */ > @@ -5575,12 +5582,11 @@ vectorizable_conversion (vec_info *vinfo, > if (multi_step_cvt) > { > gcc_assert (multi_step_cvt == 1); > - new_stmt = vect_gimple_build (vec_dest, codecvt1, vop0); > - new_temp = make_ssa_name (vec_dest, new_stmt); > + new_stmt = vect_gimple_build (cvt_op, codecvt1, vop0); > + new_temp = make_ssa_name (cvt_op, new_stmt); > gimple_assign_set_lhs (new_stmt, new_temp); > vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); > vop0 = new_temp; > - vec_dest = vec_dsts[0]; > } > new_stmt = vect_gimple_build (vec_dest, code1, vop0); > new_temp = make_ssa_name (vec_dest, new_stmt); >
diff --git a/gcc/testsuite/gcc.target/aarch64/pr110371.c b/gcc/testsuite/gcc.target/aarch64/pr110371.c new file mode 100644 index 00000000000..444e514e04f --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr110371.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +typedef struct dest +{ + double m[3][3]; +} dest; + +typedef struct src +{ + int m[3][3]; +} src; + +void +foo (dest *a, src* s) +{ + for (int i = 0; i != 3; i++) + for (int j = 0; j != 3; j++) + a->m[i][j] = s->m[i][j]; +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 85d1f3ae52c..1748555a625 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -5044,7 +5044,7 @@ vectorizable_conversion (vec_info *vinfo, gimple **vec_stmt, slp_tree slp_node, stmt_vector_for_cost *cost_vec) { - tree vec_dest; + tree vec_dest, cvt_op = NULL_TREE; tree scalar_dest; tree op0, op1 = NULL_TREE; loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo); @@ -5568,6 +5568,13 @@ vectorizable_conversion (vec_info *vinfo, case NONE: vect_get_vec_defs (vinfo, stmt_info, slp_node, ncopies, op0, &vec_oprnds0); + /* vec_dest is intermediate type operand when multi_step_cvt. */ + if (multi_step_cvt) + { + cvt_op = vec_dest; + vec_dest = vec_dsts[0]; + } + FOR_EACH_VEC_ELT (vec_oprnds0, i, vop0) { /* Arguments are ready, create the new vector stmt. */ @@ -5575,12 +5582,11 @@ vectorizable_conversion (vec_info *vinfo, if (multi_step_cvt) { gcc_assert (multi_step_cvt == 1); - new_stmt = vect_gimple_build (vec_dest, codecvt1, vop0); - new_temp = make_ssa_name (vec_dest, new_stmt); + new_stmt = vect_gimple_build (cvt_op, codecvt1, vop0); + new_temp = make_ssa_name (cvt_op, new_stmt); gimple_assign_set_lhs (new_stmt, new_temp); vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); vop0 = new_temp; - vec_dest = vec_dsts[0]; } new_stmt = vect_gimple_build (vec_dest, code1, vop0); new_temp = make_ssa_name (vec_dest, new_stmt);