From patchwork Wed Oct 30 14:42:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 99827 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 580DC3858294 for ; Wed, 30 Oct 2024 14:43:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 668083858D28 for ; Wed, 30 Oct 2024 14:42:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 668083858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 668083858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730299368; cv=none; b=HjziCKx+XIcpWVyMWrnee4QI/VBAS8uqyqexshXIgMnXZJxPojwMfk/74kF9mz6NjWkfV2Rc0yqwMERNoKdEK5FSGrUmqXyD7fB7j4SA4RZVykdU1meW2a7WxWG4oK6xwKSLe/wIZVxVP+lOOVsUjC1Izcgi61cmD/O4/p1a5Gg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730299368; c=relaxed/simple; bh=bADNR2TUVc65eAPfFhmRyIK/Wpsey/y3zroyAH+XMKQ=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=ERS5vST3YZgk+kurvFIh0udPzRYvFFkdCq6WF9xyZ1aak++dL36wm0UwRI6T4tVqccyMunfhVtQ+wyIISQZbWVO3K0A7Y8z2fZwe0RUYPCavtvKGYxQfezkX3jSKo5fj7EiHJMDTficwCbq7Y03ap9NpqoxH9A1jdJwhdFPInxc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from murzim.nue2.suse.org (unknown [10.168.4.243]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 65BEE21E00 for ; Wed, 30 Oct 2024 14:42:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730299365; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=o4lN9cW6DeG9xyKmabhp8aQEiR+Dixh1zUauJ9KYcUA=; b=TZJ2DKYw1LppbUamW7pdPwND+i+fcKlyE121eMiBr+sQDfocxoquLNfr9br1uGiPsMdsIK 4c0VWNYD+uMfL2ZrHNXLqBVBV2OAGTbPnAr8pXd3mawHvNKRqP5+8nzD8LsYmeIfwRAps2 /e6jYYONuY0QRS00GMSG73wVj1wmGF8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730299365; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=o4lN9cW6DeG9xyKmabhp8aQEiR+Dixh1zUauJ9KYcUA=; b=owY9Gf94rttKnu5+D3fUfzon1RSRjXMDOVonZyQsjbQriQm/HebFTafq6dLJ7Tjy4854iq 6zHN8gnFDbAHY+Dw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730299365; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=o4lN9cW6DeG9xyKmabhp8aQEiR+Dixh1zUauJ9KYcUA=; b=TZJ2DKYw1LppbUamW7pdPwND+i+fcKlyE121eMiBr+sQDfocxoquLNfr9br1uGiPsMdsIK 4c0VWNYD+uMfL2ZrHNXLqBVBV2OAGTbPnAr8pXd3mawHvNKRqP5+8nzD8LsYmeIfwRAps2 /e6jYYONuY0QRS00GMSG73wVj1wmGF8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730299365; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=o4lN9cW6DeG9xyKmabhp8aQEiR+Dixh1zUauJ9KYcUA=; b=owY9Gf94rttKnu5+D3fUfzon1RSRjXMDOVonZyQsjbQriQm/HebFTafq6dLJ7Tjy4854iq 6zHN8gnFDbAHY+Dw== Date: Wed, 30 Oct 2024 15:42:45 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Remove vectorizer finish_cost wrapper MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [0.15 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_SPAM_LONG(0.85)[0.243]; NEURAL_HAM_SHORT(-0.11)[-0.528]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[] X-Spam-Score: 0.15 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org Message-Id: <20241030144318.580DC3858294@sourceware.org> The inline function wraps the vector_cost class API and no longer is a good representation of the query style of that class which makes it also difficult to extend. Boostrapped and tested on x86_64-unknown-linux-gnu, pushed. * tree-vectorizer.h (finish_cost): Inline everywhere and remove. * tree-vect-loop.cc (vect_estimate_min_profitable_iters): Inline finish_cost. * tree-vect-slp.cc (vect_bb_vectorization_profitable_p): Likewise. --- gcc/tree-vect-loop.cc | 10 +++++++--- gcc/tree-vect-slp.cc | 11 ++++++----- gcc/tree-vectorizer.h | 19 +------------------ 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index b8e155b90f8..df89edac036 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -4984,9 +4984,13 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo, } /* Complete the target-specific cost calculations. */ - finish_cost (loop_vinfo->vector_costs, loop_vinfo->scalar_costs, - &vec_prologue_cost, &vec_inside_cost, &vec_epilogue_cost, - suggested_unroll_factor); + loop_vinfo->vector_costs->finish_cost (loop_vinfo->scalar_costs); + vec_prologue_cost = loop_vinfo->vector_costs->prologue_cost (); + vec_inside_cost = loop_vinfo->vector_costs->body_cost (); + vec_epilogue_cost = loop_vinfo->vector_costs->epilogue_cost (); + if (suggested_unroll_factor) + *suggested_unroll_factor + = loop_vinfo->vector_costs->suggested_unroll_factor (); if (suggested_unroll_factor && *suggested_unroll_factor > 1 && LOOP_VINFO_MAX_VECT_FACTOR (loop_vinfo) != MAX_VECTORIZATION_FACTOR diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index a7f064bb0ed..21fd4c8dc09 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -8859,9 +8859,8 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo, } while (si < li_scalar_costs.length () && li_scalar_costs[si].first == sl); - unsigned dummy; - finish_cost (scalar_target_cost_data, nullptr, - &dummy, &scalar_cost, &dummy); + scalar_target_cost_data->finish_cost (nullptr); + scalar_cost = scalar_target_cost_data->body_cost (); /* Complete the target-specific vector cost calculation. */ class vector_costs *vect_target_cost_data = init_cost (bb_vinfo, false); @@ -8872,8 +8871,10 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo, } while (vi < li_vector_costs.length () && li_vector_costs[vi].first == vl); - finish_cost (vect_target_cost_data, scalar_target_cost_data, - &vec_prologue_cost, &vec_inside_cost, &vec_epilogue_cost); + vect_target_cost_data->finish_cost (scalar_target_cost_data); + vec_prologue_cost = vect_target_cost_data->prologue_cost (); + vec_inside_cost = vect_target_cost_data->body_cost (); + vec_epilogue_cost = vect_target_cost_data->epilogue_cost (); delete scalar_target_cost_data; delete vect_target_cost_data; diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index b51771f836c..24227a69d4a 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1897,7 +1897,7 @@ extern void dump_stmt_cost (FILE *, int, enum vect_cost_for_stmt, stmt_vec_info, slp_tree, tree, int, unsigned, enum vect_cost_model_location); -/* Alias targetm.vectorize.add_stmt_cost. */ +/* Dump and add costs. */ inline unsigned add_stmt_cost (vector_costs *costs, int count, @@ -1923,8 +1923,6 @@ add_stmt_cost (vector_costs *costs, int count, enum vect_cost_for_stmt kind, return add_stmt_cost (costs, count, kind, NULL, NULL, NULL_TREE, 0, where); } -/* Alias targetm.vectorize.add_stmt_cost. */ - inline unsigned add_stmt_cost (vector_costs *costs, stmt_info_for_cost *i) { @@ -1932,21 +1930,6 @@ add_stmt_cost (vector_costs *costs, stmt_info_for_cost *i) i->vectype, i->misalign, i->where); } -/* Alias targetm.vectorize.finish_cost. */ - -inline void -finish_cost (vector_costs *costs, const vector_costs *scalar_costs, - unsigned *prologue_cost, unsigned *body_cost, - unsigned *epilogue_cost, unsigned *suggested_unroll_factor = NULL) -{ - costs->finish_cost (scalar_costs); - *prologue_cost = costs->prologue_cost (); - *body_cost = costs->body_cost (); - *epilogue_cost = costs->epilogue_cost (); - if (suggested_unroll_factor) - *suggested_unroll_factor = costs->suggested_unroll_factor (); -} - inline void add_stmt_costs (vector_costs *costs, stmt_vector_for_cost *cost_vec) {