From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id B4B063858D20 for ; Thu, 16 Nov 2023 07:00:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4B063858D20 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 B4B063858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.220.28 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700118026; cv=none; b=YMMKZJpMYU4rZ8qInlwql2KPK1f/+U6oBq06HTN0THe/e6QZ8J65EI6Grzn/xwSZOPv0PXSnb0W5GbnP1eXthJ97RgeJfhG4vWh2oE0S5n+Ae3ecRaz9OFKPT+2IFFMgocIhqYIcGR57mpsK1JhdrTuDQFF8IVmPh4PK8VFs4f4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700118026; c=relaxed/simple; bh=2Z/3CDFGEdLeDlcabUyAJ3HQ/65YqA1BtggSimPrJwY=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=eQt1W0Ht0XMz3Y8QQ/WixsBbA4rhYZpcAII+Wm6d/rWcDh7IV0wzcfbxe0Wjph7o/fEkL/QaKS8RIXHyi6a4+D0SkYd+i0fI5OMaWe7VQVFAYnlc6tXOp1S+00IPBNpHjXhTvPNddpjx8370RM2BBOmCDeRgsGgz4oZKyEaFrzs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id E9985228E2; Thu, 16 Nov 2023 07:00:23 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id CC8312C18E; Thu, 16 Nov 2023 07:00:23 +0000 (UTC) Date: Thu, 16 Nov 2023 07:00:23 +0000 (UTC) From: Richard Biener To: Tamar Christina cc: gcc-patches@gcc.gnu.org, nd@arm.com, jlaw@ventanamicro.com Subject: Re: [PATCH]middle-end: skip checking loop exits if loop malformed [PR111878] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Level: Authentication-Results: smtp-out1.suse.de; none X-Rspamd-Server: rspamd2 X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: E9985228E2 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,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, 15 Nov 2023, Tamar Christina wrote: > Hi All, > > Before my refactoring if the loop->latch was incorrect then find_loop_location > skipped checking the edges and would eventually return a dummy location. > > It turns out that a loop can have > loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS) but also not have a latch > in which case get_loop_exit_edges traps. > > This restores the old behavior. > > Bootstrapped Regtested on x86_64-pc-linux-gnu and no issues. > > Ok for master? > > Thanks, > Tamar > > gcc/ChangeLog: > > PR tree-optimization/111878 > * tree-vect-loop-manip.cc (find_loop_location): Skip edges check if > latch incorrect. > > gcc/testsuite/ChangeLog: > > PR tree-optimization/111878 > * gcc.dg/graphite/pr111878.c: New test. > > --- inline copy of patch -- > diff --git a/gcc/testsuite/gcc.dg/graphite/pr111878.c b/gcc/testsuite/gcc.dg/graphite/pr111878.c > new file mode 100644 > index 0000000000000000000000000000000000000000..6722910062e43c827e94c53b43f106af1848852a > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/graphite/pr111878.c > @@ -0,0 +1,19 @@ > +/* { dg-options "-O3 -fgraphite-identity -fsave-optimization-record" } */ > + > +int long_c2i_ltmp; > +int *long_c2i_cont; > + > +void > +long_c2i (long utmp, int i) > +{ > + int neg = 1; > + switch (long_c2i_cont[0]) > + case 0: > + neg = 0; > + for (; i; i++) > + if (neg) > + utmp |= long_c2i_cont[i] ^ 5; > + else > + utmp |= long_c2i_cont[i]; > + long_c2i_ltmp = utmp; > +} > diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc > index b9161274ce401a7307f3e61ad23aa036701190d7..ff188840c1762d0b5fb6655cb93b5a8662b31343 100644 > --- a/gcc/tree-vect-loop-manip.cc > +++ b/gcc/tree-vect-loop-manip.cc > @@ -1792,7 +1792,8 @@ find_loop_location (class loop *loop) > if (!loop) The testcase asks for the location of the root of the loop tree, I think it's more sensible to explicitly handle this case adding /* For the root of the loop tree return the function location. */ if (!loop_outer (loop)) return dump_user_location_t::from_function_decl (cfun->decl); OK with that change. Richard. > return dump_user_location_t (); > > - if (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS)) > + if (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS) > + && loop->latch != EXIT_BLOCK_PTR_FOR_FN (cfun)) > { > /* We only care about the loop location, so use any exit with location > information. */ > > > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)