From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id B89693857C61; Fri, 6 Nov 2020 10:11:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B89693857C61 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-4773] tree-optimization/97732 - fix init of SLP induction vectorization X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: f11b1f9d155bcbd797d0cb06bee2825c70ba9dd4 X-Git-Newrev: 8ebedfcd86aa5e3fc902fb442ce12c9d440c23c8 Message-Id: <20201106101113.B89693857C61@sourceware.org> Date: Fri, 6 Nov 2020 10:11:13 +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: Fri, 06 Nov 2020 10:11:13 -0000 https://gcc.gnu.org/g:8ebedfcd86aa5e3fc902fb442ce12c9d440c23c8 commit r11-4773-g8ebedfcd86aa5e3fc902fb442ce12c9d440c23c8 Author: Richard Biener Date: Fri Nov 6 09:35:27 2020 +0100 tree-optimization/97732 - fix init of SLP induction vectorization This PR exposes two issues - one that the vector builder treats &x as eligible for VECTOR_CST elements and one that SLP induction vectorization forgets to convert init elements to the vector component type which makes a difference for pointer vs. integer. 2020-11-06 Richard Biener PR tree-optimization/97732 * tree-vect-loop.c (vectorizable_induction): Convert the init elements to the vector component type. * gimple-fold.c (gimple_build_vector): Use CONSTANT_CLASS_P rather than TREE_CONSTANT to determine if elements are eligible for VECTOR_CSTs. * gcc.dg/vect/bb-slp-pr97732.c: New testcase. Diff: --- gcc/gimple-fold.c | 2 +- gcc/testsuite/gcc.dg/vect/bb-slp-pr97732.c | 11 +++++++++++ gcc/tree-vect-loop.c | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index c3fa4cb7cc1..ca38a31c3c2 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -7855,7 +7855,7 @@ gimple_build_vector (gimple_seq *seq, location_t loc, gcc_assert (builder->nelts_per_pattern () <= 2); unsigned int encoded_nelts = builder->encoded_nelts (); for (unsigned int i = 0; i < encoded_nelts; ++i) - if (!TREE_CONSTANT ((*builder)[i])) + if (!CONSTANT_CLASS_P ((*builder)[i])) { tree type = builder->type (); unsigned int nelts = TYPE_VECTOR_SUBPARTS (type).to_constant (); diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr97732.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr97732.c new file mode 100644 index 00000000000..5187090797d --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr97732.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +struct S { int a, b; } *e; +int d; + +void +foo (struct S *x) +{ + for (e = x; d; d++, e++) + e->a = e->b = (int) (__UINTPTR_TYPE__) e; +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index ef2ea3d0fb0..0ba37540d5d 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -8001,6 +8001,10 @@ vectorizable_induction (loop_vec_info loop_vinfo, { /* The scalar inits of the IVs if not vectorized. */ elt = inits[(ivn*const_nunits + eltn) % group_size]; + if (!useless_type_conversion_p (TREE_TYPE (vectype), + TREE_TYPE (elt))) + elt = gimple_build (&init_stmts, VIEW_CONVERT_EXPR, + TREE_TYPE (vectype), elt); init_elts.quick_push (elt); } /* The number of steps to add to the initial values. */