From 96d9d1620f28517de0464ab636662d9a35a92993 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 28 Oct 2019 13:43:49 +0000 Subject: [PATCH] re PR tree-optimization/92252 (ICE: Segmentation fault (in vect_stmt_to_vectorize)) 2019-10-28 Richard Biener 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. From-SVN: r277517 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr92252.c | 23 +++++++++++++++++++++++ gcc/tree-vect-slp.c | 4 ++++ 4 files changed, 38 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr92252.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 98090400569..c9daad995d7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-10-28 Richard Biener + + PR tree-optimization/92252 + * tree-vect-slp.c (vect_get_and_check_slp_defs): Adjust + STMT_VINFO_REDUC_IDX when swapping operands. + 2019-10-28 Richard Biener PR tree-optimization/92241 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 41dea35bdc6..5d1ddbe4146 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-28 Richard Biener + + PR tree-optimization/92252 + * gcc.dg/torture/pr92252.c: New testcase. + 2019-10-28 Richard Biener PR tree-optimization/92241 diff --git a/gcc/testsuite/gcc.dg/torture/pr92252.c b/gcc/testsuite/gcc.dg/torture/pr92252.c new file mode 100644 index 00000000000..eea60a044f7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr92252.c @@ -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; +} diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index e32731b6db1..b75594c36e9 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -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); -- 2.30.2