From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 6DFA63986831; Wed, 16 Jun 2021 07:48:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DFA63986831 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1493] tree-optimization/101083 - fix ICE with SLP reassoc X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: ede6c3568f383f62df7bf9234212ee80763fdf6b X-Git-Newrev: 4e56b1347687a33efa47d13d357ae3b7ab759c99 Message-Id: <20210616074816.6DFA63986831@sourceware.org> Date: Wed, 16 Jun 2021 07:48:16 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jun 2021 07:48:16 -0000 https://gcc.gnu.org/g:4e56b1347687a33efa47d13d357ae3b7ab759c99 commit r12-1493-g4e56b1347687a33efa47d13d357ae3b7ab759c99 Author: Richard Biener Date: Wed Jun 16 08:56:21 2021 +0200 tree-optimization/101083 - fix ICE with SLP reassoc This makes us pass down the vector type for the two-operand SLP node build rather than picking that from operand one which, when constant or external, could be NULL. 2021-06-16 Richard Biener PR tree-optimization/101083 * tree-vect-slp.c (vect_slp_build_two_operator_nodes): Get vectype as argument. (vect_build_slp_tree_2): Adjust. * gcc.dg/vect/pr97832-4.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/vect/pr97832-4.c | 28 ++++++++++++++++++++++++++++ gcc/tree-vect-slp.c | 5 ++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/pr97832-4.c b/gcc/testsuite/gcc.dg/vect/pr97832-4.c new file mode 100644 index 00000000000..74ae27ff873 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr97832-4.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ +/* { dg-require-effective-target vect_double } */ + +void foo1x1(double* restrict y, const double* restrict x, int clen) +{ + int xi = clen & 2; + double f_re = x[0+xi+0]; + double f_im = x[4+xi+0]; + int clen2 = (clen+xi) * 2; +#pragma GCC unroll 0 + for (int c = 0; c < clen2; c += 8) { +#pragma GCC unroll 4 + for (int k = 0; k < 4; ++k) { + double x_re = x[k]; + double x_im = x[c+4+k]; + double y_re = y[c+0+k]; + double y_im = y[c+4+k]; + y_re = y_re - x_re * f_re - x_im * f_im;; + y_im = y_im + x_re * f_im - x_im * f_re; + y[c+0+k] = y_re; + y[c+4+k] = y_im; + } + } +} + +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */ diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 9ded58592c8..8ec589b7948 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -1536,13 +1536,12 @@ vect_build_slp_tree (vec_info *vinfo, /* Helper for building an associated SLP node chain. */ static void -vect_slp_build_two_operator_nodes (slp_tree perm, +vect_slp_build_two_operator_nodes (slp_tree perm, tree vectype, slp_tree op0, slp_tree op1, stmt_vec_info oper1, stmt_vec_info oper2, vec > lperm) { unsigned group_size = SLP_TREE_LANES (op1); - tree vectype = SLP_TREE_VECTYPE (op1); slp_tree child1 = new _slp_tree; SLP_TREE_DEF_TYPE (child1) = vect_internal_def; @@ -2087,7 +2086,7 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node, for (unsigned lane = 0; lane < group_size; ++lane) lperm.quick_push (std::make_pair (chains[lane][i].code != chains[0][i].code, lane)); - vect_slp_build_two_operator_nodes (child, op0, op1, + vect_slp_build_two_operator_nodes (child, vectype, op0, op1, (chains[0][i].code == code ? op_stmt_info : other_op_stmt_info),