Richard Biener <rguent...@suse.de> writes: > Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. > > Richard. > > 2019-10-21 Richard Biener <rguent...@suse.de> > > PR tree-optimization/92162 > * tree-vect-loop.c (vect_create_epilog_for_reduction): Lookup > STMT_VINFO_REDUC_IDX in reduc_info. > * tree-vect-stmts.c (vectorizable_condition): Likewise. > > * gcc.dg/pr92162.c: New testcase. > > Index: gcc/testsuite/gcc.dg/pr92162.c > =================================================================== > --- gcc/testsuite/gcc.dg/pr92162.c (nonexistent) > +++ gcc/testsuite/gcc.dg/pr92162.c (working copy) > @@ -0,0 +1,10 @@ > +/* { dg-do compile } */ > +/* { dg-options "-Ofast" } */ > + > +short int s8; > + > +void __attribute__ ((simd)) > +gn (void) > +{ > + s8 = 0; > +} > Index: gcc/tree-vect-loop.c > =================================================================== > --- gcc/tree-vect-loop.c (revision 277242) > +++ gcc/tree-vect-loop.c (working copy) > @@ -4259,9 +4259,9 @@ vect_create_epilog_for_reduction (stmt_v > (CCOMPARE). The then and else values mirror the main VEC_COND_EXPR: > the reduction phi corresponds to NEW_PHI_TREE and the new values > correspond to INDEX_BEFORE_INCR. */ > - gcc_assert (STMT_VINFO_REDUC_IDX (stmt_info) >= 1); > + gcc_assert (STMT_VINFO_REDUC_IDX (reduc_info) >= 1); > tree index_cond_expr; > - if (STMT_VINFO_REDUC_IDX (stmt_info) == 2) > + if (STMT_VINFO_REDUC_IDX (reduc_info) == 2) > index_cond_expr = build3 (VEC_COND_EXPR, cr_index_vector_type, > ccompare, indx_before_incr, new_phi_tree); > else > Index: gcc/tree-vect-stmts.c > =================================================================== > --- gcc/tree-vect-stmts.c (revision 277242) > +++ gcc/tree-vect-stmts.c (working copy) > @@ -9818,7 +9818,7 @@ vectorizable_condition (stmt_vec_info st > return false; > reduc_info = info_for_reduction (stmt_info); > reduction_type = STMT_VINFO_REDUC_TYPE (reduc_info); > - reduc_index = STMT_VINFO_REDUC_IDX (stmt_info); > + reduc_index = STMT_VINFO_REDUC_IDX (reduc_info); > gcc_assert (reduction_type != EXTRACT_LAST_REDUCTION > || reduc_index != -1); > }
After recent changes, do we still want this last bit? reduc_index is only used by EXTRACT_LAST_REDUCTION, which wants to know which arm of the COND_EXPR is the reduction phi and which is the "new" value. AIUI this what the REDUC_IDX on the COND_EXPR now tells us. Reverting that fixes ICEs in gcc.target/aarch64/sve/clastb*. Tested on aarch64-linux-gnu (with and without SVE) and x86_64-linux-gnu. Thanks, Richard 2019-10-29 Richard Sandiford <richard.sandif...@arm.com> gcc/ * tree-vect-stmts.c (vectorizable_condition): Get the reduction index for the COND_EXPR from stmt_info rather than reduc_info. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2019-10-29 08:29:12.000000000 +0000 +++ gcc/tree-vect-stmts.c 2019-10-29 10:01:43.180808257 +0000 @@ -9903,7 +9903,7 @@ vectorizable_condition (stmt_vec_info st return false; reduc_info = info_for_reduction (stmt_info); reduction_type = STMT_VINFO_REDUC_TYPE (reduc_info); - reduc_index = STMT_VINFO_REDUC_IDX (reduc_info); + reduc_index = STMT_VINFO_REDUC_IDX (stmt_info); gcc_assert (reduction_type != EXTRACT_LAST_REDUCTION || reduc_index != -1); }