Bootstrap and regtest running on x86_64-unknown-linux-gnu.
Richard. 2019-10-28 Richard Biener <rguent...@suse.de> PR tree-optimization/92252 * tree-vect-slp.c (vect_get_and_check_slp_defs): Adjust STMT_VINFO_REDUC_IDX when swapping operands. * gcc.dg/torture/pr92252.c: New testcase. Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c (revision 277504) +++ gcc/tree-vect-slp.c (working copy) @@ -563,6 +563,10 @@ again: { swap_ssa_operands (stmt, gimple_assign_rhs2_ptr (stmt), gimple_assign_rhs3_ptr (stmt)); + if (STMT_VINFO_REDUC_IDX (stmt_info) == 1) + STMT_VINFO_REDUC_IDX (stmt_info) = 2; + else if (STMT_VINFO_REDUC_IDX (stmt_info) == 2) + STMT_VINFO_REDUC_IDX (stmt_info) = 1; bool honor_nans = HONOR_NANS (TREE_OPERAND (cond, 0)); code = invert_tree_comparison (TREE_CODE (cond), honor_nans); gcc_assert (code != ERROR_MARK); Index: gcc/testsuite/gcc.dg/torture/pr92252.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr92252.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr92252.c (working copy) @@ -0,0 +1,23 @@ +/* { do-do compile } */ +/* { dg-additional-options "-ftree-vectorize" } */ + +long int ar; +int dt; + +long int +pc (unsigned long int q3, int zw) +{ + long int em = 0; + + while (zw < 1) + { + q3 = zw * 2ul; + if (q3 != 0) + for (ar = 0; ar < 2; ++ar) + em = dt; + + ++zw; + } + + return em; +}