From patchwork Wed Sep 18 13:04:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1986808 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ybqmNAru; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=3e5g+lgd; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ybqmNAru; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=3e5g+lgd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X7zQk6Xttz1y1m for ; Wed, 18 Sep 2024 23:05:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22CFB3858424 for ; Wed, 18 Sep 2024 13:05:17 +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 8302B3858C41 for ; Wed, 18 Sep 2024 13:04:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8302B3858C41 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 8302B3858C41 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=1726664695; cv=none; b=ZMBvPlqCsxn6NZnd0cwjlDujjQxum9kOwCYt/VxerR/tQGzjgpRrpxmb62mdxIhyHCT4rI7QIucZqjOFiyzLJBCYcFvapTdXghq7nMMl2kJfAfI3IgXiHlDXJIKMSfo2b5NtRvxGLHC7vNpifzcVTpwf8SbLPWs0MjLENOaO0rw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726664695; c=relaxed/simple; bh=T+u8IzEe/hdDng55KF6YgqunCjI3EwV3jMQsDHYm3f0=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version:Message-Id; b=CzLcHCcgtPOfyeXVqj+NGI3TyYD5ABWkxDQxbTd//XElo2u5Xa/0D/wKWbFmYizUlVOBZfHGB/cGBJxoSopUjgQGMuGwZmQCbdhwMP+e1L25NQGPUUmgeQW0M7zZXWmdyFwFpcSZ/ytHWErPNEApds3p/eHZSMdsENxtDl4L2jY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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 5E6C3229D2; Wed, 18 Sep 2024 13:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1726664692; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=6Z+fe83claRBBjf79cvf69drHyx7XdYycC6EBjLhqUc=; b=ybqmNAruFZzQuTE+mzUuiYPfaozkEyb3XIes8pHlurYhMq1b4ocSsmWfpZRzcsoy0b/aBr zzTgS+ZYZeAKeCQfsE/EFgviFWYE0zPjyM97NQO+Gtxg22dVk7Hp8fcK6lFObwHClFZMzQ 0q8mrSymrqgOSTkslbED9pkJ1uFkd1E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1726664692; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=6Z+fe83claRBBjf79cvf69drHyx7XdYycC6EBjLhqUc=; b=3e5g+lgdSfzb6IkoSimQi0EbRFkRGbD9hfNSPg4SQMOPUlCA591Dyu3vEcfNF5d9WTJUkT g0a0tvcsWES9I+AQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=ybqmNAru; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=3e5g+lgd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1726664692; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=6Z+fe83claRBBjf79cvf69drHyx7XdYycC6EBjLhqUc=; b=ybqmNAruFZzQuTE+mzUuiYPfaozkEyb3XIes8pHlurYhMq1b4ocSsmWfpZRzcsoy0b/aBr zzTgS+ZYZeAKeCQfsE/EFgviFWYE0zPjyM97NQO+Gtxg22dVk7Hp8fcK6lFObwHClFZMzQ 0q8mrSymrqgOSTkslbED9pkJ1uFkd1E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1726664692; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=6Z+fe83claRBBjf79cvf69drHyx7XdYycC6EBjLhqUc=; b=3e5g+lgdSfzb6IkoSimQi0EbRFkRGbD9hfNSPg4SQMOPUlCA591Dyu3vEcfNF5d9WTJUkT g0a0tvcsWES9I+AQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3EFC613508; Wed, 18 Sep 2024 13:04:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id X0HFDfTP6mY/MQAAD6G6ig (envelope-from ); Wed, 18 Sep 2024 13:04:52 +0000 Date: Wed, 18 Sep 2024 15:04:47 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: richard.sandiford@arm.com Subject: [PATCH] Fail vectorization when not using SLP and --param vect-force-slp == 1 MIME-Version: 1.0 Message-Id: <20240918130452.3EFC613508@imap1.dmz-prg2.suse.org> X-Rspamd-Queue-Id: 5E6C3229D2 X-Spam-Level: X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,imap1.dmz-prg2.suse.org:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MISSING_XM_UA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[suse.de:dkim,tree-vect-stmts.cc:url,imap1.dmz-prg2.suse.org:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,tree-vect-loop.cc:url]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.51 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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~incoming=patchwork.ozlabs.org@gcc.gnu.org The following adds --param vect-force-slp to enable the transition to full SLP. Full SLP is enforced during stmt analysis where it detects failed SLP discovery and at loop analysis time where it avoids analyzing a loop with SLP disabled. Failure to SLP results in vectorization to fail. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress; I'll push after that finishes. This gives you the ability to dial ahead in time and evaluate your target as to what happens when we pull the trigger. Richard. * params.def (vect-force-slp): New param, default 0. * doc/invoke.texi (--param vect-force-slp): Document. * tree-vect-loop.cc (vect_analyze_loop_2): When analyzing without SLP but --param vect-force-slp is 1 fail. * tree-vect-stmts.cc (vect_analyze_stmt): Fail vectorization for non-SLP stmts when --param vect-force-slp is 1. --- gcc/doc/invoke.texi | 3 +++ gcc/params.opt | 4 ++++ gcc/tree-vect-loop.cc | 6 ++++++ gcc/tree-vect-stmts.cc | 6 ++++++ 4 files changed, 19 insertions(+) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 511b8c8d311..b91fb9c9cca 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -16955,6 +16955,9 @@ this parameter. The default value of this parameter is 50. @item vect-induction-float Enable loop vectorization of floating point inductions. +@item vect-force-slp +Force the use of SLP when vectorizing, fail if not possible. + @item vrp-block-limit Maximum number of basic blocks before VRP switches to a lower memory algorithm. diff --git a/gcc/params.opt b/gcc/params.opt index c17ba17b91b..949b4754498 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -1198,6 +1198,10 @@ The maximum factor which the loop vectorizer applies to the cost of statements i Common Joined UInteger Var(param_vect_induction_float) Init(1) IntegerRange(0, 1) Param Optimization Enable loop vectorization of floating point inductions. +-param=vect-force-slp= +Common Joined UInteger Var(param_vect_force_slp) Init(0) IntegerRange(0, 1) Param Optimization +Force the use of SLP when vectorizing, fail if not possible. + -param=vrp-block-limit= Common Joined UInteger Var(param_vrp_block_limit) Init(150000) Optimization Param Maximum number of basic blocks before VRP switches to a fast model with less memory requirements. diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 62c7f90779f..d42694d1974 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -2891,6 +2891,12 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal, /* This is the point where we can re-start analysis with SLP forced off. */ start_over: + /* When we arrive here with SLP disabled and we are supposed + to use SLP for everything fail vectorization. */ + if (!slp && param_vect_force_slp) + return opt_result::failure_at (vect_location, + "may need non-SLP handling\n"); + /* Apply the suggested unrolling factor, this was determined by the backend during finish_cost the first time we ran the analyzis for this vector mode. */ diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index b1353c91fce..495f45e40e6 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -13353,6 +13353,12 @@ vect_analyze_stmt (vec_info *vinfo, return opt_result::success (); } + /* When we arrive here with a non-SLP statement and we are supposed + to use SLP for everything fail vectorization. */ + if (!node && param_vect_force_slp) + return opt_result::failure_at (stmt_info->stmt, + "needs non-SLP handling\n"); + ok = true; if (!bb_vinfo && (STMT_VINFO_RELEVANT_P (stmt_info)