From: Thomas Schwinge <thomas@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Subject: Reduce scope of a few 'class loop *loop' variables (was: [PATCH v4] Use range-based for loops for traversing loops)
Date: Wed, 24 Nov 2021 15:24:20 +0100 [thread overview]
Message-ID: <874k81y6ln.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <45eedc54-f588-b720-d6c7-8a23a36752d0@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 751 bytes --]
Hi!
On 2021-07-30T15:58:36+0800, "Kewen.Lin" <linkw@linux.ibm.com> wrote:
> on 2021/7/30 下午3: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.
Grüße
Thomas
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Reduce-scope-of-a-few-class-loop-loop-variables.patch --]
[-- Type: text/x-diff, Size: 6484 bytes --]
From 6051ff3a4ba0b8f44ecb262e4553f8a471c66237 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 30 Jul 2021 09:23:20 +0200
Subject: [PATCH] Reduce scope of a few 'class loop *loop' variables
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.
* 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.
---
gcc/cfgloop.c | 3 +--
gcc/ipa-fnsummary.c | 3 +--
gcc/loop-init.c | 2 +-
gcc/loop-invariant.c | 4 ++--
gcc/predict.c | 3 +--
gcc/tree-loop-distribution.c | 2 +-
gcc/tree-vectorizer.c | 5 ++---
7 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 20c24c13c36..3190d12b2ce 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -1398,7 +1398,6 @@ verify_loop_structure (void)
{
unsigned *sizes, i, j;
basic_block bb, *bbs;
- class loop *loop;
int err = 0;
edge e;
unsigned num = number_of_loops (cfun);
@@ -1689,7 +1688,7 @@ verify_loop_structure (void)
for (; exit; exit = exit->next_e)
eloops++;
- for (loop = bb->loop_father;
+ for (class loop *loop = bb->loop_father;
loop != e->dest->loop_father
/* When a loop exit is also an entry edge which
can happen when avoiding CFG manipulations
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, bool early)
if (nonconstant_names.exists () && !early)
{
ipa_fn_summary *s = ipa_fn_summaries->get (node);
- class loop *loop;
unsigned max_loop_predicates = opt_for_fn (node->decl,
param_ipa_max_loop_predicates);
@@ -2978,7 +2977,7 @@ analyze_function_body (struct cgraph_node *node, bool 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 = loops_for_fn (cfun)->tree_root->inner;
+ for (class loop *loop = loops_for_fn (cfun)->tree_root->inner;
loop != NULL; loop = loop->next)
{
ipa_predicate loop_stride = true;
diff --git a/gcc/loop-init.c b/gcc/loop-init.c
index 04054ef6222..f0931a99661 100644
--- a/gcc/loop-init.c
+++ b/gcc/loop-init.c
@@ -201,7 +201,6 @@ fix_loop_structure (bitmap changed_bbs)
{
basic_block bb;
int record_exits = 0;
- class loop *loop;
unsigned old_nloops, i;
timevar_push (TV_LOOP_INIT);
@@ -279,6 +278,7 @@ fix_loop_structure (bitmap changed_bbs)
/* Finally free deleted loops. */
bool any_deleted = false;
+ class loop *loop;
FOR_EACH_VEC_ELT (*get_loops (cfun), i, loop)
if (loop && loop->header == NULL)
{
diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index fca0c2b24be..5eee2e5c9f8 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -2134,7 +2134,7 @@ calculate_loop_reg_pressure (void)
basic_block bb;
rtx_insn *insn;
rtx link;
- class loop *loop, *parent;
+ class loop *parent;
for (auto loop : loops_list (cfun, 0))
if (loop->aux == NULL)
@@ -2151,7 +2151,7 @@ calculate_loop_reg_pressure (void)
if (curr_loop == current_loops->tree_root)
continue;
- for (loop = curr_loop;
+ for (class loop *loop = curr_loop;
loop != current_loops->tree_root;
loop = loop_outer (loop))
bitmap_ior_into (&LOOP_DATA (loop)->regs_live, DF_LR_IN (bb));
diff --git a/gcc/predict.c b/gcc/predict.c
index 68b11135680..3cb4e3c0eb5 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -1927,7 +1927,6 @@ predict_extra_loop_exits (edge exit_edge)
static void
predict_loops (void)
{
- class loop *loop;
basic_block bb;
hash_set <class loop *> with_recursion(10);
@@ -1941,7 +1940,7 @@ predict_loops (void)
&& (decl = gimple_call_fndecl (gsi_stmt (gsi))) != NULL
&& recursive_call_p (current_function_decl, decl))
{
- loop = bb->loop_father;
+ class loop *loop = bb->loop_father;
while (loop && !with_recursion.add (loop))
loop = loop_outer (loop);
}
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 583c01a42d8..c9e18739165 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -3737,7 +3737,6 @@ prepare_perfect_loop_nest (class loop *loop)
unsigned int
loop_distribution::execute (function *fun)
{
- class loop *loop;
bool changed = false;
basic_block bb;
control_dependences *cd = NULL;
@@ -3845,6 +3844,7 @@ loop_distribution::execute (function *fun)
/* Destroy loop bodies that could not be reused. Do this late as we
otherwise can end up refering to stale data in control dependences. */
unsigned i;
+ class loop *loop;
FOR_EACH_VEC_ELT (loops_to_be_destroyed, i, loop)
destroy_loop (loop);
diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index 0e1cee99bae..f4a2873a91e 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -1209,7 +1209,6 @@ pass_vectorize::execute (function *fun)
unsigned int i;
unsigned int num_vectorized_loops = 0;
unsigned int vect_loops_num;
- class loop *loop;
hash_table<simduid_to_vf> *simduid_to_vf_htab = NULL;
hash_table<simd_array_to_simduid> *simd_array_to_simduid_htab = NULL;
bool any_ifcvt_loops = false;
@@ -1293,7 +1292,7 @@ pass_vectorize::execute (function *fun)
if (any_ifcvt_loops)
for (i = 1; i < number_of_loops (fun); i++)
{
- loop = get_loop (fun, i);
+ class loop *loop = get_loop (fun, i);
if (loop && loop->dont_vectorize)
{
gimple *g = vect_loop_vectorized_call (loop);
@@ -1342,7 +1341,7 @@ pass_vectorize::execute (function *fun)
loop_vec_info loop_vinfo;
bool has_mask_store;
- loop = get_loop (fun, i);
+ class loop *loop = get_loop (fun, i);
if (!loop || !loop->aux)
continue;
loop_vinfo = (loop_vec_info) loop->aux;
--
2.33.0
next prev parent reply other threads:[~2021-11-24 14:24 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-19 6:20 [RFC/PATCH] Use range-based for loops for traversing loops Kewen.Lin
2021-07-19 6:26 ` Andrew Pinski
2021-07-20 8:56 ` Kewen.Lin
2021-07-19 14:08 ` Jonathan Wakely
2021-07-20 8:56 ` Kewen.Lin
2021-07-19 14:34 ` Richard Biener
2021-07-20 8:57 ` Kewen.Lin
2021-07-19 15:59 ` Martin Sebor
2021-07-20 8:58 ` Kewen.Lin
2021-07-20 9:49 ` Jonathan Wakely
2021-07-20 9:50 ` Jonathan Wakely
2021-07-20 14:42 ` Kewen.Lin
2021-07-20 14:36 ` [PATCH v2] " Kewen.Lin
2021-07-22 12:56 ` Richard Biener
2021-07-22 12:56 ` Richard Biener
2021-07-23 8:41 ` [PATCH] Make loops_list support an optional loop_p root Kewen.Lin
2021-07-23 16:26 ` Martin Sebor
2021-07-27 2:25 ` Kewen.Lin
2021-07-29 8:01 ` Richard Biener
2021-07-30 5:20 ` [PATCH v2] " Kewen.Lin
2021-08-03 12:08 ` Richard Biener
2021-08-04 2:36 ` [PATCH v3] " Kewen.Lin
2021-08-04 10:01 ` Richard Biener
2021-08-04 10:47 ` Kewen.Lin
2021-08-04 12:04 ` Richard Biener
2021-08-05 8:50 ` Kewen.Lin
2021-07-23 8:35 ` [PATCH v3] Use range-based for loops for traversing loops Kewen.Lin
2021-07-23 16:10 ` Martin Sebor
2021-07-27 2:10 ` [PATCH v4] " Kewen.Lin
2021-07-29 7:48 ` Richard Biener
2021-07-30 7:18 ` Thomas Schwinge
2021-07-30 7:58 ` Kewen.Lin
2021-11-24 14:24 ` Thomas Schwinge [this message]
2021-11-24 16:58 ` Reduce scope of a few 'class loop *loop' variables (was: [PATCH v4] Use range-based for loops for traversing loops) Martin Jambor
2021-11-24 19:44 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874k81y6ln.fsf@euler.schwinge.homeip.net \
--to=thomas@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).