From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1984) id 2CB6E3858C98; Wed, 15 Nov 2023 14:55:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CB6E3858C98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700060138; bh=NloveovbTr9ypu9VJwh7IO6264OZdjdw/eu5XhXllks=; h=From:To:Subject:Date:From; b=Ezz07VD/tHNbTf4YwF7yZPTVDThJV685T4LlVd1vOZ3lryGkiHr29nViUgQJf6KYj iufQnL831w9s0Rjzkf4PxjDQng3tRTHMTzWz2uhgDf6vtZsdv4aoA+5OhNRp+dzmQ7 asm55nILavcXgOGvnySVaish7DOFxazHAUlQ/XfM= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tamar Christina To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/tnfchris/heads/gcc-14-early-break)] middle-end: Update loop form analysis to support early break X-Act-Checkin: gcc X-Git-Author: Tamar Christina X-Git-Refname: refs/users/tnfchris/heads/gcc-14-early-break X-Git-Oldrev: e049151fd3fc653055ac87ed88718c4efa163fc6 X-Git-Newrev: 0bfccd4b6ba450f93c74440f98b325958af33830 Message-Id: <20231115145538.2CB6E3858C98@sourceware.org> Date: Wed, 15 Nov 2023 14:55:38 +0000 (GMT) List-Id: https://gcc.gnu.org/g:0bfccd4b6ba450f93c74440f98b325958af33830 commit 0bfccd4b6ba450f93c74440f98b325958af33830 Author: Tamar Christina Date: Thu Nov 2 17:05:47 2023 +0000 middle-end: Update loop form analysis to support early break Diff: --- gcc/tree-vect-loop.cc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index f406c59c2c3..cd83cc0a67a 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -1700,12 +1700,12 @@ vect_compute_single_scalar_iteration_cost (loop_vec_info loop_vinfo) loop_vinfo->scalar_costs->finish_cost (nullptr); } - /* Function vect_analyze_loop_form. Verify that certain CFG restrictions hold, including: - the loop has a pre-header - - the loop has a single entry and exit + - the loop has a single entry + - nested loops can have only a single exit. - the loop exit condition is simple enough - the number of iterations can be analyzed, i.e, a countable loop. The niter could be analyzed under some assumptions. */ @@ -1841,10 +1841,14 @@ vect_analyze_loop_form (class loop *loop, vect_loop_form_info *info) "not vectorized: latch block not empty.\n"); /* Make sure the exit is not abnormal. */ - if (exit_e->flags & EDGE_ABNORMAL) - return opt_result::failure_at (vect_location, - "not vectorized:" - " abnormal loop exit edge.\n"); + auto_vec exits = get_loop_exit_edges (loop); + for (edge e : exits) + { + if (e->flags & EDGE_ABNORMAL) + return opt_result::failure_at (vect_location, + "not vectorized:" + " abnormal loop exit edge.\n"); + } info->conds = vect_get_loop_niters (loop, exit_e, &info->assumptions, @@ -1920,6 +1924,10 @@ vect_create_loop_vinfo (class loop *loop, vec_info_shared *shared, LOOP_VINFO_IV_EXIT (loop_vinfo) = info->loop_exit; + /* Check to see if we're vectorizing multiple exits. */ + LOOP_VINFO_EARLY_BREAKS (loop_vinfo) + = !LOOP_VINFO_LOOP_CONDS (loop_vinfo).is_empty (); + if (info->inner_loop_cond) { stmt_vec_info inner_loop_cond_info @@ -11691,7 +11699,7 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call) /* Make sure there exists a single-predecessor exit bb. Do this before versioning. */ edge e = LOOP_VINFO_IV_EXIT (loop_vinfo); - if (! single_pred_p (e->dest)) + if (! single_pred_p (e->dest) && !LOOP_VINFO_EARLY_BREAKS (loop_vinfo)) { split_loop_exit_edge (e, true); if (dump_enabled_p ())