From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 6CEBA3857814; Fri, 19 Nov 2021 13:53:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CEBA3857814 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/loop-unswitch-improvement)] Small while(1) loop refactoring. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/loop-unswitch-improvement X-Git-Oldrev: ea2954df43d4162af23a20c84f4c5485463977ac X-Git-Newrev: cb8fe628c409af126e5eae6fe4c15349eed7f9aa Message-Id: <20211119135319.6CEBA3857814@sourceware.org> Date: Fri, 19 Nov 2021 13:53:19 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Nov 2021 13:53:19 -0000 https://gcc.gnu.org/g:cb8fe628c409af126e5eae6fe4c15349eed7f9aa commit cb8fe628c409af126e5eae6fe4c15349eed7f9aa Author: Martin Liska Date: Mon Nov 15 13:17:24 2021 +0100 Small while(1) loop refactoring. Diff: --- gcc/tree-ssa-loop-unswitch.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index fe4dacc0833..d77914e2ba5 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -307,11 +307,10 @@ tree_unswitch_single_loop (class loop *loop, int num) } } - i = 0; bbs = get_loop_body (loop); found = loop->num_nodes; - while (1) + for (unsigned i = 0; true; i++) { /* Find a bb to unswitch on. */ for (; i < loop->num_nodes; i++) @@ -351,10 +350,7 @@ tree_unswitch_single_loop (class loop *loop, int num) } /* Do not unswitch too much. */ else if (num > param_max_unswitch_level) - { - i++; - continue; - } + continue; /* In nested tree_unswitch_single_loop first optimize all conditions using entry checks, then discover still reachable blocks in the loop and find the condition only among those still reachable bbs. */ @@ -362,7 +358,6 @@ tree_unswitch_single_loop (class loop *loop, int num) { if (found == loop->num_nodes) found = i; - i++; continue; } else @@ -372,7 +367,6 @@ tree_unswitch_single_loop (class loop *loop, int num) } update_stmt (stmt); - i++; } if (num != 0)