From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id D59693858036; Mon, 15 Nov 2021 15:48:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D59693858036 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: b2e1ac548594c5f482b6e9e9cfa25f9cc090bf84 X-Git-Newrev: 6a57bc376b44ff38d9dfad54fe1667b2608a8853 Message-Id: <20211115154804.D59693858036@sourceware.org> Date: Mon, 15 Nov 2021 15:48:04 +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: Mon, 15 Nov 2021 15:48:04 -0000 https://gcc.gnu.org/g:6a57bc376b44ff38d9dfad54fe1667b2608a8853 commit 6a57bc376b44ff38d9dfad54fe1667b2608a8853 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)