From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 240CE3857C65 for ; Wed, 24 Nov 2021 16:58:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 240CE3857C65 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 0FA961FD2F; Wed, 24 Nov 2021 16:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637773102; 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=5rq14EEyHCNi9PiyThvK3hFkj6CRvxUNFXHV/L7KB80=; b=qIRdyi31LKx15DzL13+sVrs0F60983O+CoT02AnThfh/I/No7rjxNTU4zaaT4uZKy/QwnM kbZw2aVIJD6Q2YumhzdH/z9dFl8i5GHLzyXfVmXIZvDzpKwKptkxwnLI21h24PkB860vax btjTDviniCIqzHO2PBh2IMxodzWzgQo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637773102; 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=5rq14EEyHCNi9PiyThvK3hFkj6CRvxUNFXHV/L7KB80=; b=i1CY1cLeaSJWL0jVxzXFtI1fvnrhpaVbdDECZ2CRn5AuKnHjdAeLjsLhR/hHadNLeQs3L0 va3ZLYuD9UvugxAA== Received: from suse.cz (virgil.suse.cz [10.100.13.50]) (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 F0179A3B81; Wed, 24 Nov 2021 16:58:21 +0000 (UTC) From: Martin Jambor To: Thomas Schwinge Cc: gcc-patches@gcc.gnu.org Subject: Re: Reduce scope of a few 'class loop *loop' variables (was: [PATCH v4] Use range-based for loops for traversing loops) In-Reply-To: <874k81y6ln.fsf@euler.schwinge.homeip.net> References: <0a8b77ba-1d54-1eff-b54d-d2cb1e769e09@linux.ibm.com> <79a93b1f-6417-234c-a785-fdc598dfb92c@linux.ibm.com> <878s1o8e2s.fsf@euler.schwinge.homeip.net> <45eedc54-f588-b720-d6c7-8a23a36752d0@linux.ibm.com> <874k81y6ln.fsf@euler.schwinge.homeip.net> User-Agent: Notmuch/0.34.1 (https://notmuchmail.org) Emacs/27.2 (x86_64-suse-linux-gnu) Date: Wed, 24 Nov 2021 17:58:21 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.2 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Nov 2021 16:58:24 -0000 Hi, On Wed, Nov 24 2021, Thomas Schwinge wrote: > Hi! > > On 2021-07-30T15:58:36+0800, "Kewen.Lin" wrote: >> on 2021/7/30 =E4=B8=8B=E5=8D=883:18, Thomas Schwinge wrote: >>> Curious why in some instances we're not removing the 'class loop *loop' >>> declaration, I had a look, and this may suggest some further clean-up? >> >> [...] I like your nice proposed further clean-up, >> thanks for doing that! > > Ping for my patch to "Reduce scope of a few 'class loop *loop' variables", > see attached. > [...] > > Further clean-up after commit e41ba804ba5f5ca433e09238d561b1b4c8b10985 > "Use range-based for loops for traversing loops". No functional change. > > gcc/ > * cfgloop.c (verify_loop_structure): Reduce scope of > 'class loop *loop' variable. > * ipa-fnsummary.c (analyze_function_body): Likewise. FWIW, the ipa-fnsummary.c hunk is OK (and better-that-expected clean-up too, because it avoids the loop variable being hidden by another with the same name in an earlier loop). Thanks, Martin > * loop-init.c (fix_loop_structure): Likewise. > * loop-invariant.c (calculate_loop_reg_pressure): Likewise. > * predict.c (predict_loops): Likewise. > * tree-loop-distribution.c (loop_distribution::execute): Likewise. > * tree-vectorizer.c (pass_vectorize::execute): Likewise. [...] > diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c > index 7e9201a554a..cb13d2e4b3c 100644 > --- a/gcc/ipa-fnsummary.c > +++ b/gcc/ipa-fnsummary.c > @@ -2934,7 +2934,6 @@ analyze_function_body (struct cgraph_node *node, bo= ol early) > if (nonconstant_names.exists () && !early) > { > ipa_fn_summary *s =3D ipa_fn_summaries->get (node); > - class loop *loop; > unsigned max_loop_predicates =3D opt_for_fn (node->decl, > param_ipa_max_loop_predicates); >=20=20 > @@ -2978,7 +2977,7 @@ analyze_function_body (struct cgraph_node *node, bo= ol early) > /* To avoid quadratic behavior we analyze stride predicates only > with respect to the containing loop. Thus we simply iterate > over all defs in the outermost loop body. */ > - for (loop =3D loops_for_fn (cfun)->tree_root->inner; > + for (class loop *loop =3D loops_for_fn (cfun)->tree_root->inner; > loop !=3D NULL; loop =3D loop->next) > { > ipa_predicate loop_stride =3D true;