From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 548353858C56; Thu, 13 Oct 2022 14:28:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 548353858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665671304; bh=LwMNcUrFC79zOY3Ja6ANOIKaG81+lf+KkLwEnxOQDQU=; h=From:To:Subject:Date:From; b=YpaujM0Dn/aqZkoA7Vlb33I46lRvPe2mSFv+EX1K08T/qSaI6I6diJzinos1FuSSs fyctdyJUK3gTA3yciQZZTvhJwrchTqdF8MGcnjzpdx86S4HYx06IVkaC2kuIujzMfX V5UCzmcUIcj2edSICOBfUwCNYCfqz5ixnTI05NYw= 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 r13-3276] tree-optimization/107247 - reduce SLP reduction accumulator X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 4b7966191a69238c6d6fd5537b3e77c3a4027eb2 X-Git-Newrev: e5139d18dfb8130876ea59178e8471fb1b34bb80 Message-Id: <20221013142824.548353858C56@sourceware.org> Date: Thu, 13 Oct 2022 14:28:24 +0000 (GMT) List-Id: https://gcc.gnu.org/g:e5139d18dfb8130876ea59178e8471fb1b34bb80 commit r13-3276-ge5139d18dfb8130876ea59178e8471fb1b34bb80 Author: Richard Biener Date: Thu Oct 13 14:56:01 2022 +0200 tree-optimization/107247 - reduce SLP reduction accumulator The following makes sure to reduce a multi-vector SLP reduction accumulator to a single vector using vector operations if easily possible (if the number of lanes in the vector type is a multiple of the number of scalar accumulators). PR tree-optimization/107247 * tree-vect-loop.cc (vect_create_epilog_for_reduction): Reduce multi vector SLP reduction accumulators. Check the adjusted number of accumulator vectors against one for the re-use in the epilogue. Diff: --- gcc/tree-vect-loop.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index b1442a93581..98a943d8a4b 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -5642,9 +5642,21 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, we may end up with more than one vector result. Here we reduce them to one vector. + The same is true for a SLP reduction, e.g., + # a1 = phi + # b1 = phi + a2 = operation (a1) + b2 = operation (a2), + + where we can end up with more than one vector as well. We can + easily accumulate vectors when the number of vector elements is + a multiple of the SLP group size. + The same is true if we couldn't use a single defuse cycle. */ if (REDUC_GROUP_FIRST_ELEMENT (stmt_info) || direct_slp_reduc + || (slp_reduc + && constant_multiple_p (TYPE_VECTOR_SUBPARTS (vectype), group_size)) || ncopies > 1) { gimple_seq stmts = NULL; @@ -6233,7 +6245,7 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, /* Record this operation if it could be reused by the epilogue loop. */ if (STMT_VINFO_REDUC_TYPE (reduc_info) == TREE_CODE_REDUCTION - && vec_num == 1) + && reduc_inputs.length () == 1) loop_vinfo->reusable_accumulators.put (scalar_results[0], { orig_reduc_input, reduc_info });