From e57d9a82996838e73cc5470a1f3367e9c616b947 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 16 Jan 2018 15:13:05 +0000 Subject: [PATCH] re PR tree-optimization/83867 (ICE: Segmentation fault in nested_in_vect_loop_p) 2018-01-16 Richard Biener PR tree-optimization/83867 * tree-vect-stmts.c (vect_transform_stmt): Precompute nested_in_vect_loop_p since the scalar stmt may get invalidated. * gcc.dg/vect/pr83867.c: New testcase. From-SVN: r256746 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/vect/pr83867.c | 20 ++++++++++++++++++++ gcc/tree-vect-stmts.c | 9 ++++++--- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr83867.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9b7bf83cb77..055e924a8b0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-01-16 Richard Biener + + PR tree-optimization/83867 + * tree-vect-stmts.c (vect_transform_stmt): Precompute + nested_in_vect_loop_p since the scalar stmt may get invalidated. + 2018-01-16 Jakub Jelinek PR c/83844 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ec9f4695cc3..ae578285db0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-16 Richard Biener + + PR tree-optimization/83867 + * gcc.dg/vect/pr83867.c: New testcase. + 2018-01-16 Jakub Jelinek PR c/83844 diff --git a/gcc/testsuite/gcc.dg/vect/pr83867.c b/gcc/testsuite/gcc.dg/vect/pr83867.c new file mode 100644 index 00000000000..aab5bb7378e --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr83867.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O -ftrapv" } */ + +int +k5 (int u5, int aw) +{ + int v6; + + while (u5 < 1) + { + while (v6 < 4) + ++v6; + + v6 = 0; + aw += u5 > 0; + ++u5; + } + + return aw; +} diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 0f74772fe7e..3f8eb9242a3 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -9426,6 +9426,11 @@ vect_transform_stmt (gimple *stmt, gimple_stmt_iterator *gsi, gcc_assert (slp_node || !PURE_SLP_STMT (stmt_info)); gimple *old_vec_stmt = STMT_VINFO_VEC_STMT (stmt_info); + bool nested_p = (STMT_VINFO_LOOP_VINFO (stmt_info) + && nested_in_vect_loop_p + (LOOP_VINFO_LOOP (STMT_VINFO_LOOP_VINFO (stmt_info)), + stmt)); + switch (STMT_VINFO_TYPE (stmt_info)) { case type_demotion_vec_info_type: @@ -9525,9 +9530,7 @@ vect_transform_stmt (gimple *stmt, gimple_stmt_iterator *gsi, /* Handle inner-loop stmts whose DEF is used in the loop-nest that is being vectorized, but outside the immediately enclosing loop. */ if (vec_stmt - && STMT_VINFO_LOOP_VINFO (stmt_info) - && nested_in_vect_loop_p (LOOP_VINFO_LOOP ( - STMT_VINFO_LOOP_VINFO (stmt_info)), stmt) + && nested_p && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type && (STMT_VINFO_RELEVANT (stmt_info) == vect_used_in_outer || STMT_VINFO_RELEVANT (stmt_info) == -- 2.30.2