From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id EA0313858D1E; Fri, 11 Mar 2022 14:03:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA0313858D1E 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-7612] target/104762 - vectorization costs of CONSTRUCTORs X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: db494fd68d12f3b49ad5f4747c234f3a94d10c72 X-Git-Newrev: 69619acd8d9b5856f5af6e5323d9c7c4ec9ad08f Message-Id: <20220311140319.EA0313858D1E@sourceware.org> Date: Fri, 11 Mar 2022 14:03:19 +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, 11 Mar 2022 14:03:20 -0000 https://gcc.gnu.org/g:69619acd8d9b5856f5af6e5323d9c7c4ec9ad08f commit r12-7612-g69619acd8d9b5856f5af6e5323d9c7c4ec9ad08f Author: Richard Biener Date: Fri Mar 11 11:51:13 2022 +0100 target/104762 - vectorization costs of CONSTRUCTORs After accounting for GPR -> XMM move cost for vec_construct the base cost needs adjustments to not double-cost those. This also lowers the cost when such move is not necessary. 2022-03-11 Richard Biener PR target/104762 * config/i386/i386.cc (ix86_builtin_vectorization_cost): Do not cost the first lane of SSE pieces as inserts for vec_construct. Diff: --- gcc/config/i386/i386.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 4121f986221..23bedea92bd 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -22597,16 +22597,21 @@ ix86_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, case vec_construct: { - /* N element inserts into SSE vectors. */ - int cost = TYPE_VECTOR_SUBPARTS (vectype) * ix86_cost->sse_op; + int n = TYPE_VECTOR_SUBPARTS (vectype); + /* N - 1 element inserts into an SSE vector, the possible + GPR -> XMM move is accounted for in add_stmt_cost. */ + if (GET_MODE_BITSIZE (mode) <= 128) + return (n - 1) * ix86_cost->sse_op; /* One vinserti128 for combining two SSE vectors for AVX256. */ - if (GET_MODE_BITSIZE (mode) == 256) - cost += ix86_vec_cost (mode, ix86_cost->addss); + else if (GET_MODE_BITSIZE (mode) == 256) + return ((n - 2) * ix86_cost->sse_op + + ix86_vec_cost (mode, ix86_cost->addss)); /* One vinserti64x4 and two vinserti128 for combining SSE and AVX256 vectors to AVX512. */ else if (GET_MODE_BITSIZE (mode) == 512) - cost += 3 * ix86_vec_cost (mode, ix86_cost->addss); - return cost; + return ((n - 4) * ix86_cost->sse_op + + 3 * ix86_vec_cost (mode, ix86_cost->addss)); + gcc_unreachable (); } default: