From patchwork Tue Jan 9 12:31:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 186349 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp76344dyi; Tue, 9 Jan 2024 04:36:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGW1FKLy0qObbuTmQe+H0fWZKMcC6H8Jj560pggmXAKJhA6O9lkDHqRFzhgY9E4vknVFXLx X-Received: by 2002:ac8:7d0f:0:b0:429:9874:ee65 with SMTP id g15-20020ac87d0f000000b004299874ee65mr3451176qtb.124.1704803806755; Tue, 09 Jan 2024 04:36:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704803806; cv=pass; d=google.com; s=arc-20160816; b=aJpcN7QmlNdurZR+53esetz6qUaBfIlgXd0uGPuavQrIHlt6A6tEQDVcYyJhE3cSMv MCetMoMA9BgRgOVXItYELNsSTZ5iKcFfa0kCgF89f81W4LSdMtjxHfts3ANx9zsNSiHP YNruxOyH7plB0ULZFdsBvR47f74ch73H2Y+Sa2X1PSp5wNS6VKKiONmZfOUYBtRK3ycr s7Ud6mTUTm4e7E6jzssdeOEmx/vWAqMYQEH2jG+TnkHNdtURIIEM0c/IiK+x9Vti9myy Thied97YAzHt6jhkBqnaYvwWlIrnDVP/fWSNxhAGylcO0Nq/5BG0ljYQnRnHHiVlsyV4 TPVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:errors-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :subject:to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=rePrT2/BH3ao5TkXVZ7Zy1A7FVsB1ANOVNZQS6axiaQ=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=y2cf1ZhERIwlCxqLqYBTi6rM30CwpfVYVTGUEAetmPTnoSXkGe1mszAHKl3+GJ8u43 tHxfRIDjLiP4rcIeUluJEnMPWndlHLWRpq1UaMLHEHKp+wCdmBIszERxClK9Eyz+yzYK 4X88PTjj75txCim7r/PA7W+P5mQZoqtODNYfE/CpLTkNdMtwA+MG3EtFWrkinaI3uYBY llsSeGdwWVMbMqJ7sQssBI9X4+pj4AvHA76NwWwDXyuBTys1+sRekOi47Pz9LfSKjtZo ZKyh9PgIj2FSlyxv5hVH2FyzrzNP02DP4dAlg9JYVzX9F/EnM/UalPEAPr7+PVAlkLCu tTyA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=aVZiVK1b; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=aVZiVK1b; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=tkso8sZ8; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h10-20020ac8584a000000b004299a70ceb1si2007750qth.381.2024.01.09.04.36.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 04:36:46 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=aVZiVK1b; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=aVZiVK1b; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=tkso8sZ8; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 555D13858292 for ; Tue, 9 Jan 2024 12:36:46 +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 [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id B48BE3858C74 for ; Tue, 9 Jan 2024 12:36:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B48BE3858C74 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 B48BE3858C74 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704803762; cv=none; b=U2vvM5Z8DFjgpM2EDYLbax737JPZM1/8vPn8w4yuxHHD39UAa8ZC2vdfumrBBsFDjGW7ZyzFy+aQiBYpZpOIcVj/zdjcP92iI5oIt9tKV22OnhqsqpGFOOWzDTaMTjs4QWDv23Xxl/hiFlr94Sh8Y8/AfhvU2g7KqKu6vZWMH9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704803762; c=relaxed/simple; bh=gGJupm+SJjbWn1YBu5lvWATpp7thWXgge7S0eWN7Ihk=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=Tp7Un7qw7KkUZ6RpPMTvoW0iyVjnrrseeQCF+T6nld3Ba3waVvgL9ML+zfDkjAjAPglwgTDLsuCwyw+zJWNZo1gFXxPZso/bebmrEJ3w2rqOKXIXkmGJGMobKhIKNG7qm44iPcJRGO5zYIgv6ZcoPZEnL8pz5JvjWksVdSL0ZlA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (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 B15BA21DAC for ; Tue, 9 Jan 2024 12:35:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704803759; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=rePrT2/BH3ao5TkXVZ7Zy1A7FVsB1ANOVNZQS6axiaQ=; b=aVZiVK1bakylOt9VOXxvZcdT3ho1nr7BN4dydCQFL/kNTRff906xqpNVUsUi1RHK44hbP2 GOOF0MXilWg7aA8h21EpnmDpan23a338nnPAnX8UH60h16nlSHUMBYQ1H4SZjn7jiT8EVt 2wdgfJ1LkDHRADNiONbWyIzZwV35QsY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704803759; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=rePrT2/BH3ao5TkXVZ7Zy1A7FVsB1ANOVNZQS6axiaQ=; b=tkso8sZ8KB0rP3gd1HDZBx4miB73PDznjifk4n6Qlwxk4L+Cqsjx1g9TGTnwkE76jO3F/3 t/SU66UNC4dz/aCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704803759; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=rePrT2/BH3ao5TkXVZ7Zy1A7FVsB1ANOVNZQS6axiaQ=; b=aVZiVK1bakylOt9VOXxvZcdT3ho1nr7BN4dydCQFL/kNTRff906xqpNVUsUi1RHK44hbP2 GOOF0MXilWg7aA8h21EpnmDpan23a338nnPAnX8UH60h16nlSHUMBYQ1H4SZjn7jiT8EVt 2wdgfJ1LkDHRADNiONbWyIzZwV35QsY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704803759; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=rePrT2/BH3ao5TkXVZ7Zy1A7FVsB1ANOVNZQS6axiaQ=; b=tkso8sZ8KB0rP3gd1HDZBx4miB73PDznjifk4n6Qlwxk4L+Cqsjx1g9TGTnwkE76jO3F/3 t/SU66UNC4dz/aCw== Date: Tue, 9 Jan 2024 13:31:00 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/113026 - fix vector epilogue maximum iter bound MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 2.85 X-Spamd-Result: default: False [2.85 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(2.99)[0.998]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; NEURAL_HAM_LONG(-0.99)[-0.991]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-1.56)[92.12%] X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+ouuuleilei=gmail.com@gcc.gnu.org Message-Id: <20240109123646.555D13858292@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787616356535361332 X-GMAIL-MSGID: 1787616356535361332 The late amendment with a limit based on VF was redundant and wrong for peeled early exits. The following moves the adjustment done when we don't have a skip edge down to the place where the already existing VF based max iter check is done and removes the amendment. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/113026 * tree-vect-loop-manip.cc (vect_do_peeling): Remove redundant and wrong niter bound setting. Move niter bound adjustment down. --- gcc/tree-vect-loop-manip.cc | 47 ++++++++++++------------------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index 927f76a0947..915fc7c1238 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -3364,38 +3364,6 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1, bb_before_epilog->count = single_pred_edge (bb_before_epilog)->count (); bb_before_epilog = loop_preheader_edge (epilog)->src; } - else - { - /* When we do not have a loop-around edge to the epilog we know - the vector loop covered at least VF scalar iterations unless - we have early breaks and the epilog will cover at most - VF - 1 + gap peeling iterations. - Update any known upper bound with this knowledge. */ - if (! LOOP_VINFO_EARLY_BREAKS (loop_vinfo)) - { - if (epilog->any_upper_bound) - epilog->nb_iterations_upper_bound -= lowest_vf; - if (epilog->any_likely_upper_bound) - epilog->nb_iterations_likely_upper_bound -= lowest_vf; - if (epilog->any_estimate) - epilog->nb_iterations_estimate -= lowest_vf; - } - unsigned HOST_WIDE_INT const_vf; - if (vf.is_constant (&const_vf)) - { - const_vf += LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) - 1; - if (epilog->any_upper_bound) - epilog->nb_iterations_upper_bound - = wi::umin (epilog->nb_iterations_upper_bound, const_vf); - if (epilog->any_likely_upper_bound) - epilog->nb_iterations_likely_upper_bound - = wi::umin (epilog->nb_iterations_likely_upper_bound, - const_vf); - if (epilog->any_estimate) - epilog->nb_iterations_estimate - = wi::umin (epilog->nb_iterations_estimate, const_vf); - } - } /* If loop is peeled for non-zero constant times, now niters refers to orig_niters - prolog_peeling, it won't overflow even the orig_niters @@ -3486,6 +3454,21 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1, if (LOOP_VINFO_EARLY_BREAKS (loop_vinfo)) iterate_fix_dominators (CDI_DOMINATORS, doms, false); + /* When we do not have a loop-around edge to the epilog we know + the vector loop covered at least VF scalar iterations unless + we have early breaks. + Update any known upper bound with this knowledge. */ + if (! skip_vector + && ! LOOP_VINFO_EARLY_BREAKS (loop_vinfo)) + { + if (epilog->any_upper_bound) + epilog->nb_iterations_upper_bound -= lowest_vf; + if (epilog->any_likely_upper_bound) + epilog->nb_iterations_likely_upper_bound -= lowest_vf; + if (epilog->any_estimate) + epilog->nb_iterations_estimate -= lowest_vf; + } + unsigned HOST_WIDE_INT bound; if (bound_scalar.is_constant (&bound)) {