From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id E55213857731 for ; Wed, 14 Feb 2024 15:18:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E55213857731 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 E55213857731 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=1707923937; cv=none; b=GU6305x7TRWg7IkHSt0tMCW98Uyw0BjbPFv3ZSmtaTP82GP4ke8u00KEJcqUP75bO9CrUGRbwBTWrW0HSKZtVI5qfKsB+vMP4mbH8/R3yXy2VD7SnIu1Y/LYoX1J9boVWxwJfh89BzlpuXGITVD+3YA7/68HKIRm1xnxi5aBhZ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707923937; c=relaxed/simple; bh=X1ArLvafyNEH+1o6IoKY4UnyfFcH5NAWYeOqJaeMWKE=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: Mime-Version:Subject:Date:Message-Id:To; b=RqEjxpiytWgO9Kl4c2d+gMzB01e5hLTWzJ/wWnac0P+xMFceN5ZVsVzZoyHHL/f6VkF8Z3v6kgREdSYeCxciatDzryl3DcL+Bw30LdncjtD84HtgoZwvce3yVVELQcVaGD/7ZKK01GccbPtNrdDHSotBgTmSkHivDkKqFHt6Wbo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (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 94E86221EE; Wed, 14 Feb 2024 15:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707923934; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UpvlfGBFR5iQE2hNMN2hGOJ2rXVG8uq3VNDnorhqgTY=; b=hH66uKFqfhnSglLiGV4lTkBIza96jHLFkPCK+aa57Wyd6nZ820ncDNld6T+Ncy+o9rrxDp onZlGVzrGj+kMy23yiDpSmyXgINbuEBWzYwKMuqNVIRoAFefqUzvZg5XLDi+uBRKzIxI3G brfoVBVmFF5qsGJjHsqqqY+bgYynHuI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707923934; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UpvlfGBFR5iQE2hNMN2hGOJ2rXVG8uq3VNDnorhqgTY=; b=onECryV02RY0U7AiN7XieAoIQ2dnSbpMEQ6hhfannmyM/dBq+5CJIn57f1YpZM1Kf5DSpv XS0nFARcurTy2+Bw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707923934; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UpvlfGBFR5iQE2hNMN2hGOJ2rXVG8uq3VNDnorhqgTY=; b=hH66uKFqfhnSglLiGV4lTkBIza96jHLFkPCK+aa57Wyd6nZ820ncDNld6T+Ncy+o9rrxDp onZlGVzrGj+kMy23yiDpSmyXgINbuEBWzYwKMuqNVIRoAFefqUzvZg5XLDi+uBRKzIxI3G brfoVBVmFF5qsGJjHsqqqY+bgYynHuI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707923934; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UpvlfGBFR5iQE2hNMN2hGOJ2rXVG8uq3VNDnorhqgTY=; b=onECryV02RY0U7AiN7XieAoIQ2dnSbpMEQ6hhfannmyM/dBq+5CJIn57f1YpZM1Kf5DSpv XS0nFARcurTy2+Bw== Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 836C513A1A; Wed, 14 Feb 2024 15:18:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id v5QPIN7ZzGU/HQAAn2gu4w (envelope-from ); Wed, 14 Feb 2024 15:18:54 +0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Richard Biener Mime-Version: 1.0 (1.0) Subject: Re: [PATCH]middle-end: inspect all exits for additional annotations for loop. Date: Wed, 14 Feb 2024 16:18:43 +0100 Message-Id: References: Cc: gcc-patches@gcc.gnu.org, nd , jlaw@ventanamicro.com In-Reply-To: To: Tamar Christina X-Mailer: iPhone Mail (21D61) Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -3.30 X-Spamd-Result: default: False [-3.30 / 50.00]; ARC_NA(0.00)[]; SUBJECT_ENDS_SPACES(0.50)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; MV_CASE(0.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; TO_DN_SOME(0.00)[]; BAYES_HAM(-3.00)[100.00%]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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 List-Id: > Am 14.02.2024 um 16:16 schrieb Tamar Christina : >=20 > =EF=BB=BF >>=20 >>=20 >> I think this isn't entirely good. For simple cases for >> do {} while the condition ends up in the latch while for while () {} >> loops it ends up in the header. In your case the latch isn't empty >> so it doesn't end up with the conditional. >>=20 >> I think your patch is OK to the point of looking at all loop exit >> sources but you should elide the special-casing of header and >> latch since it's really only exit conditionals that matter. >>=20 >=20 > That makes sense, since in both cases the edges are in the respective > blocks. Should have thought about it more. >=20 > So how about this one. >=20 > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. >=20 > Ok for master? Ok Richard=20 > Thanks, > Tamar >=20 > gcc/ChangeLog: >=20 > * tree-cfg.cc (replace_loop_annotate): Inspect loop edges for annotatio= ns. >=20 > gcc/testsuite/ChangeLog: >=20 > * gcc.dg/vect/vect-novect_gcond.c: New test. >=20 > --- inline copy of patch --- >=20 > diff --git a/gcc/testsuite/gcc.dg/vect/vect-novect_gcond.c b/gcc/testsuite= /gcc.dg/vect/vect-novect_gcond.c > new file mode 100644 > index 0000000000000000000000000000000000000000..01e69cbef9d51b234c08a400c7= 8dc078d53252f1 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/vect/vect-novect_gcond.c > @@ -0,0 +1,39 @@ > +/* { dg-add-options vect_early_break } */ > +/* { dg-require-effective-target vect_early_break_hw } */ > +/* { dg-require-effective-target vect_int } */ > +/* { dg-additional-options "-O3" } */ > + > +/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */ > + > +#include "tree-vect.h" > + > +#define N 306 > +#define NEEDLE 136 > + > +int table[N]; > + > +__attribute__ ((noipa)) > +int foo (int i, unsigned short parse_tables_n) > +{ > + parse_tables_n >>=3D 9; > + parse_tables_n +=3D 11; > +#pragma GCC novector > + while (i < N && parse_tables_n--) > + table[i++] =3D 0; > + > + return table[NEEDLE]; > +} > + > +int main () > +{ > + check_vect (); > + > +#pragma GCC novector > + for (int j =3D 0; j < N; j++) > + table[j] =3D -1; > + > + if (foo (0, 0xFFFF) !=3D 0) > + __builtin_abort (); > + > + return 0; > +} > diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc > index cdd439fe7506e7bc33654ffa027b493f23d278ac..bdffc3b4ed277724e81b7dd67f= e7966e8ece0c13 100644 > --- a/gcc/tree-cfg.cc > +++ b/gcc/tree-cfg.cc > @@ -320,12 +320,9 @@ replace_loop_annotate (void) >=20 > for (auto loop : loops_list (cfun, 0)) > { > - /* First look into the header. */ > - replace_loop_annotate_in_block (loop->header, loop); > - > - /* Then look into the latch, if any. */ > - if (loop->latch) > - replace_loop_annotate_in_block (loop->latch, loop); > + /* Check all exit source blocks for annotations. */ > + for (auto e : get_loop_exit_edges (loop)) > + replace_loop_annotate_in_block (e->src, loop); >=20 > /* Push the global flag_finite_loops state down to individual loops.= */ > loop->finite_p =3D flag_finite_loops; >