From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 954D8385E019 for ; Wed, 14 Feb 2024 13:41:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 954D8385E019 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 954D8385E019 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707918091; cv=none; b=hZvdhSu7qACxInLDGPCvIkPXHIiCZt/NV3HHCkQVUTYVTyuyzCG/X3sUvd6JGB92/VyWPE8f/NL+xswcfjQaKfpHVtgL8xwEAcHYuRF076F2cr33RsNHUHu5BFcRJ1oMMeXyB7yQ+YH3RSD96ooeRh4CVes53X6Jh632YIB83C0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707918091; c=relaxed/simple; bh=6gwhPCcQsr3QdscRfgBHL6QU7CpAmjqVRIUuhawIXAQ=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:Message-ID:MIME-Version; b=uyun6NM0VGaOJZIJ5YMkSaaIfqDIIm9004EyDoRg36axpJTgoYpaQGUzBcJCg+bFbwBVFInuWWzv/AVIZ11yd1jpdFbg/5SR6ZFOkGeHShLLEiE3WR12PKIED9lIge1qRkKgTTZ2tCSulu8VHg/u4RmHJSf55bZ9IG5g+fRB+uk= 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-out2.suse.de (Postfix) with ESMTPS id 865081F805; Wed, 14 Feb 2024 13:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707918087; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PLUotrrOV/brZHl6vCj883H5+3woHKvTxV2vbpEVW+Q=; b=EkAfJW/imQldJEIXRUb53luVwlHCm+ltNoQ53eiUQCHgVU4a5CcW7OwK95X7NMxXb8mIdI 5OMrXkbAZu58OCKId+/y34q2qj5m3RnskZ0U7d8NseHRJDqsZhHHmIafGCcdL7F+9haWEb vqkVOIxReashs9o5Yixlp+vRWLcsMM0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707918087; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PLUotrrOV/brZHl6vCj883H5+3woHKvTxV2vbpEVW+Q=; b=LlUkafsVLm8+bOOy2txVEgsmvUZzZ1WUTENUw3bx+gHEv5xiJ4snKhndfzBjLTKgUgA5jS rh3XWT0m9HhATLCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707918087; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PLUotrrOV/brZHl6vCj883H5+3woHKvTxV2vbpEVW+Q=; b=EkAfJW/imQldJEIXRUb53luVwlHCm+ltNoQ53eiUQCHgVU4a5CcW7OwK95X7NMxXb8mIdI 5OMrXkbAZu58OCKId+/y34q2qj5m3RnskZ0U7d8NseHRJDqsZhHHmIafGCcdL7F+9haWEb vqkVOIxReashs9o5Yixlp+vRWLcsMM0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707918087; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PLUotrrOV/brZHl6vCj883H5+3woHKvTxV2vbpEVW+Q=; b=LlUkafsVLm8+bOOy2txVEgsmvUZzZ1WUTENUw3bx+gHEv5xiJ4snKhndfzBjLTKgUgA5jS rh3XWT0m9HhATLCA== Date: Wed, 14 Feb 2024 14:41:27 +0100 (CET) From: Richard Biener To: Tamar Christina cc: gcc-patches@gcc.gnu.org, nd@arm.com, jlaw@ventanamicro.com Subject: Re: [PATCH]middle-end: inspect all exits for additional annotations for loop. In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-3.10 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%] X-Spam-Level: X-Spam-Score: -3.10 X-Spam-Status: No, score=-11.0 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: On Wed, 14 Feb 2024, Tamar Christina wrote: > Hi All, > > Attaching a pragma to a loop which has a complex condition often gets the pragma > dropped. e.g. > > #pragma GCC novector > while (i < N && parse_tables_n--) > > before lowering this is represented as: > > if (ANNOTATE_EXPR ) ... > > But after lowering the condition is broken appart and attached to the final > component of the expression: > > if (parse_tables_n.2_2 != 0) goto ; else goto ; > : > iftmp.1D.4452 = 1; > goto ; > : > iftmp.1D.4452 = 0; > : > D.4451 = .ANNOTATE (iftmp.1D.4452, 2, 0); > if (D.4451 != 0) goto ; else goto ; > : > > and it's never heard from again because during replace_loop_annotate we only > inspect the loop header and latch for annotations. > > Since annotations were supposed to apply to the loop as a whole this fixes it > by also checking the loop exit src blocks for annotations. > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? 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. 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. Richard. > Thanks, > Tamar > > gcc/ChangeLog: > > * tree-cfg.cc (replace_loop_annotate): Inspect loop edges for annotations. > > gcc/testsuite/ChangeLog: > > * gcc.dg/vect/vect-novect_gcond.c: New test. > > --- inline copy of patch -- > 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..01e69cbef9d51b234c08a400c78dc078d53252f1 > --- /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 >>= 9; > + parse_tables_n += 11; > +#pragma GCC novector > + while (i < N && parse_tables_n--) > + table[i++] = 0; > + > + return table[NEEDLE]; > +} > + > +int main () > +{ > + check_vect (); > + > +#pragma GCC novector > + for (int j = 0; j < N; j++) > + table[j] = -1; > + > + if (foo (0, 0xFFFF) != 0) > + __builtin_abort (); > + > + return 0; > +} > diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc > index cdd439fe7506e7bc33654ffa027b493f23d278ac..a29681bffb902d2d05e3f18764ab519aacb3c5bc 100644 > --- a/gcc/tree-cfg.cc > +++ b/gcc/tree-cfg.cc > @@ -327,6 +327,10 @@ replace_loop_annotate (void) > if (loop->latch) > replace_loop_annotate_in_block (loop->latch, loop); > > + /* Then also check all other exits. */ > + for (auto e : get_loop_exit_edges (loop)) > + replace_loop_annotate_in_block (e->src, loop); > + > /* Push the global flag_finite_loops state down to individual loops. */ > loop->finite_p = flag_finite_loops; > } > > > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)