From a7b3509eb6aa51d696be5edba6f4e451ceff03a0 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 3 Jul 2019 10:25:22 +0200 Subject: [PATCH] re PR tree-optimization/91033 (ICE in vect_analyze_loop, at tree-vect-loop.c:2416) PR tree-optimization/91033 * tree-vectorizer.h (vect_mark_stmts_to_be_vectorized, vect_analyze_data_refs): Add bool * arguments. * tree-vect-data-refs.c (vect_analyze_data_refs): Add fatal argument, if failure is due to scatter/gather, set *fatal to false if non-NULL. * tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Likewise. * tree-vect-loop.c (vect_analyze_loop_2): Adjust vect_mark_stmts_to_be_vectorized and vect_analyze_data_refs callers. * tree-vect-slp.c (vect_slp_analyze_bb_1): Adjust vect_analyze_data_refs caller. * gcc.target/i386/pr91033.c: New test. From-SVN: r272989 --- gcc/ChangeLog | 11 +++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr91033.c | 15 +++++++++++++++ gcc/tree-vect-data-refs.c | 18 +++++++++++------- gcc/tree-vect-loop.c | 4 ++-- gcc/tree-vect-slp.c | 2 +- gcc/tree-vect-stmts.c | 8 ++++++-- gcc/tree-vectorizer.h | 4 ++-- 8 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr91033.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2e7c74f..743b85d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,16 @@ 2019-07-03 Jakub Jelinek + PR tree-optimization/91033 + * tree-vectorizer.h (vect_mark_stmts_to_be_vectorized, + vect_analyze_data_refs): Add bool * arguments. + * tree-vect-data-refs.c (vect_analyze_data_refs): Add fatal argument, + if failure is due to scatter/gather, set *fatal to false if non-NULL. + * tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Likewise. + * tree-vect-loop.c (vect_analyze_loop_2): Adjust + vect_mark_stmts_to_be_vectorized and vect_analyze_data_refs callers. + * tree-vect-slp.c (vect_slp_analyze_bb_1): Adjust + vect_analyze_data_refs caller. + * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE__SCANTEMP_ clause. * tree.h (OMP_CLAUSE_DECL): Use OMP_CLAUSE__SCANTEMP_ instead of diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6be1739..fc960bb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-07-03 Jakub Jelinek + + PR tree-optimization/91033 + * gcc.target/i386/pr91033.c: New test. + 2019-07-03 Bob Duff * gnat.dg/task2.adb, gnat.dg/task2_pkg.adb, diff --git a/gcc/testsuite/gcc.target/i386/pr91033.c b/gcc/testsuite/gcc.target/i386/pr91033.c new file mode 100644 index 0000000..43d99d5 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr91033.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/91033 */ +/* { dg-do compile { target pthread } } */ +/* { dg-options "-march=knl -O2 -fopenmp-simd -ftree-parallelize-loops=2" } */ + +#define N 1024 +int a[N]; + +void +foo (void) +{ + int i; + #pragma omp simd simdlen (4) + for (i = 0; i < N; ++i) + a[i] = a[i] + 1; +} diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 20c8815..cf9cee5 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -4160,7 +4160,7 @@ vect_find_stmt_data_reference (loop_p loop, gimple *stmt, */ opt_result -vect_analyze_data_refs (vec_info *vinfo, poly_uint64 *min_vf) +vect_analyze_data_refs (vec_info *vinfo, poly_uint64 *min_vf, bool *fatal) { struct loop *loop = NULL; unsigned int i; @@ -4386,12 +4386,16 @@ vect_analyze_data_refs (vec_info *vinfo, poly_uint64 *min_vf) as_a (vinfo), &gs_info) || !get_vectype_for_scalar_type (TREE_TYPE (gs_info.offset))) - return opt_result::failure_at - (stmt_info->stmt, - (gatherscatter == GATHER) ? - "not vectorized: not suitable for gather load %G" : - "not vectorized: not suitable for scatter store %G", - stmt_info->stmt); + { + if (fatal) + *fatal = false; + return opt_result::failure_at + (stmt_info->stmt, + (gatherscatter == GATHER) + ? "not vectorized: not suitable for gather load %G" + : "not vectorized: not suitable for scatter store %G", + stmt_info->stmt); + } STMT_VINFO_GATHER_SCATTER_P (stmt_info) = gatherscatter; } } diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 5176474..c46cd9d 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -1901,7 +1901,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal, unsigned *n_stmts) /* Analyze the data references and also adjust the minimal vectorization factor according to the loads and stores. */ - ok = vect_analyze_data_refs (loop_vinfo, &min_vf); + ok = vect_analyze_data_refs (loop_vinfo, &min_vf, &fatal); if (!ok) { if (dump_enabled_p ()) @@ -1932,7 +1932,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal, unsigned *n_stmts) /* Data-flow analysis to detect stmts that do not need to be vectorized. */ - ok = vect_mark_stmts_to_be_vectorized (loop_vinfo); + ok = vect_mark_stmts_to_be_vectorized (loop_vinfo, &fatal); if (!ok) { if (dump_enabled_p ()) diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 930cd797..1aaf10e 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -2861,7 +2861,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin, /* Analyze the data references. */ - if (!vect_analyze_data_refs (bb_vinfo, &min_vf)) + if (!vect_analyze_data_refs (bb_vinfo, &min_vf, NULL)) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 8379a08..313b1b9 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -608,7 +608,7 @@ process_use (stmt_vec_info stmt_vinfo, tree use, loop_vec_info loop_vinfo, This pass detects such stmts. */ opt_result -vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo) +vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo, bool *fatal) { struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo); @@ -778,7 +778,11 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo) = process_use (stmt_vinfo, gs_info.offset, loop_vinfo, relevant, &worklist, true); if (!res) - return res; + { + if (fatal) + *fatal = false; + return res; + } } } /* while worklist */ diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 5fc8f9f..0dd29f8 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1501,7 +1501,7 @@ extern unsigned record_stmt_cost (stmt_vector_for_cost *, int, extern stmt_vec_info vect_finish_replace_stmt (stmt_vec_info, gimple *); extern stmt_vec_info vect_finish_stmt_generation (stmt_vec_info, gimple *, gimple_stmt_iterator *); -extern opt_result vect_mark_stmts_to_be_vectorized (loop_vec_info); +extern opt_result vect_mark_stmts_to_be_vectorized (loop_vec_info, bool *); extern tree vect_get_store_rhs (stmt_vec_info); extern tree vect_get_vec_def_for_operand_1 (stmt_vec_info, enum vect_def_type); extern tree vect_get_vec_def_for_operand (tree, stmt_vec_info, tree = NULL); @@ -1559,7 +1559,7 @@ extern bool vect_check_gather_scatter (stmt_vec_info, loop_vec_info, gather_scatter_info *); extern opt_result vect_find_stmt_data_reference (loop_p, gimple *, vec *); -extern opt_result vect_analyze_data_refs (vec_info *, poly_uint64 *); +extern opt_result vect_analyze_data_refs (vec_info *, poly_uint64 *, bool *); extern void vect_record_base_alignments (vec_info *); extern tree vect_create_data_ref_ptr (stmt_vec_info, tree, struct loop *, tree, tree *, gimple_stmt_iterator *, -- 2.7.4