From: Richard Biener Date: Wed, 14 Nov 2018 09:19:28 +0000 (+0000) Subject: re PR tree-optimization/87974 (ICE in vect_get_vec_def_for_stmt_copy) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f711908bf61e39432965db84ed12424cc6f251e1;p=gcc.git re PR tree-optimization/87974 (ICE in vect_get_vec_def_for_stmt_copy) 2018-11-14 Richard Biener PR tree-optimization/87974 * tree-vect-loop.c (vectorizable_reduction): When computing the vectorized reduction PHI vector type ignore constant and external defs. * g++.dg/opt/pr87974.C: New testcase. From-SVN: r266099 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cbd89695b1d..f1f2c4c957a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-11-14 Richard Biener + + PR tree-optimization/87974 + * tree-vect-loop.c (vectorizable_reduction): When computing + the vectorized reduction PHI vector type ignore constant + and external defs. + 2018-11-14 Jakub Jelinek PR tree-optimization/87977 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eb871d03d7c..767da5380f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-11-14 Richard Biener + + PR tree-optimization/87974 + * g++.dg/opt/pr87974.C: New testcase. + 2018-11-14 Jakub Jelinek PR tree-optimization/87977 diff --git a/gcc/testsuite/g++.dg/opt/pr87974.C b/gcc/testsuite/g++.dg/opt/pr87974.C new file mode 100644 index 00000000000..4b070d2a6f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr87974.C @@ -0,0 +1,33 @@ +// { dg-do compile { target c++11 } } +// { dg-options "-O3" } + +struct h { + typedef int &c; +}; +class i { + struct j { + using c = int *; + }; + using as = j::c; +}; +template class k { +public: + using as = i::as; + h::c operator[](long l) { + k::as d = 0; + return d[l]; + } +}; +class : public k { } a; +long c, f; +void m() +{ + for (long b; b <= 6; b++) + for (long g; g < b; g++) { + unsigned long e = g; + c = 0; + for (; c < b; c++) + f = e >>= 1; + a[g] = f; + } +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index dccddee1cf0..dac6bb87847 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -6066,13 +6066,17 @@ vectorizable_reduction (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, return true; gassign *reduc_stmt = as_a (reduc_stmt_info->stmt); + code = gimple_assign_rhs_code (reduc_stmt); for (unsigned k = 1; k < gimple_num_ops (reduc_stmt); ++k) { tree op = gimple_op (reduc_stmt, k); if (op == phi_result) continue; - if (k == 1 - && gimple_assign_rhs_code (reduc_stmt) == COND_EXPR) + if (k == 1 && code == COND_EXPR) + continue; + bool is_simple_use = vect_is_simple_use (op, loop_vinfo, &dt); + gcc_assert (is_simple_use); + if (dt == vect_constant_def || dt == vect_external_def) continue; if (!vectype_in || (GET_MODE_SIZE (SCALAR_TYPE_MODE (TREE_TYPE (vectype_in)))