From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128006 invoked by alias); 22 May 2019 13:44:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 127998 invoked by uid 89); 22 May 2019 13:44:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=H*f:sk:334e438, H*f:sk:F220452, H*f:sk:BYAPR01, H*f:sk:SDDu9WF X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 May 2019 13:44:11 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2032FAD87; Wed, 22 May 2019 13:44:09 +0000 (UTC) Date: Wed, 22 May 2019 13:44:00 -0000 From: Michael Matz To: Richard Biener cc: Feng Xue OS , "gcc-patches@gcc.gnu.org" , Jeff Law Subject: Re: [PATCH] Remove empty loop with assumed finiteness (PR tree-optimization/89713) In-Reply-To: Message-ID: References: <334e4382-d393-4a83-0fa6-abd80a949f44@redhat.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-IsSubscribed: yes X-SW-Source: 2019-05/txt/msg01505.txt.bz2 Hi, On Tue, 21 May 2019, Richard Biener wrote: > > Index: gcc/tree-ssa-dce.c > > =================================================================== > > --- gcc/tree-ssa-dce.c (revision 271415) > > +++ gcc/tree-ssa-dce.c (working copy) > > @@ -417,7 +417,7 @@ find_obviously_necessary_stmts (bool agg > > } > > > > FOR_EACH_LOOP (loop, 0) > > - if (!finite_loop_p (loop)) > > + if (!loop_has_exit_edges (loop)) > > { > > if (dump_file) > > fprintf (dump_file, "cannot prove finiteness of loop > > %i\n", loop->num); > > Bootstrapped / tested on x86_64-unknown-linux-gnu. Fallout: > > FAIL: gcc.dg/loop-unswitch-1.c scan-tree-dump unswitch ";; Unswitching loop" > FAIL: gcc.dg/predict-9.c scan-tree-dump-times profile_estimate "first > match heuristics: 2.20%" 3 > FAIL: gcc.dg/predict-9.c scan-tree-dump-times profile_estimate "first > match heuristics: 5.50%" 1 These contain infinite loops without other sideeffects. > FAIL: gcc.dg/graphite/scop-19.c scan-tree-dump-times graphite "number > of SCoPs: 0" 2 Loop without sideeffects. > ... > UNRESOLVED: gcc.dg/tree-ssa/20040211-1.c scan-tree-dump cddce2 "if " why unresolved? Anyway, conditionally infinite loop, but without side effects. > FAIL: gcc.dg/tree-ssa/loop-10.c scan-tree-dump-times optimized "if " 3 Probably removes one more loop, which is conditionally infinite, but no side-effects. > FAIL: gcc.dg/tree-ssa/pr84648.c scan-tree-dump-times cddce1 "Found > loop 1 to be finite: upper bound found" 1 finite, no side-effect. > FAIL: gcc.dg/tree-ssa/split-path-6.c scan-tree-dump-times split-paths > "Duplicating join block" 3 AFAICS all loops therein contain side-effects, though the one in lookharder() only an invalid one, which might be optimized away, so that might be it. But this would need to be looked at. > FAIL: gcc.dg/tree-ssa/ssa-thread-12.c scan-tree-dump thread2 "FSM" > FAIL: gcc.dg/tree-ssa/ssa-thread-12.c scan-tree-dump thread3 "FSM" If everything is properly inlined, this contains two nested side-effect-free loops. > FAIL: gcc.dg/uninit-28-gimple.c (test for bogus messages, line 9) But this one doesn't contain a loop at all!? > I didn't look if the testcases are sensible for loop removal (or what > actually happens). IMHO most testcases above (perhaps except gcc.dg/uninit-28-gimple.c and tree-ssa/split-path-6.c) are sensible for loop removal if mere memory accesses and possible infiniteness don't count as side-effects. Ciao, Michael.