public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/44794 - avoid excessive RTL unrolling on epilogues
Date: Thu, 9 Mar 2023 11:15:17 +0000 (UTC)	[thread overview]
Message-ID: <20230309111517.M4uvDz9Dsuy0MnXGRI1CbM8iAspoiiDcKiM19nrCrIs@z> (raw)

The following adjusts tree_[transform_and_]unroll_loop to set an
upper bound on the number of iterations on the epilogue loop it
creates.  For the testcase at hand which involves array prefetching
this avoids applying RTL unrolling to them when -funroll-loops is
specified.

Other users of this API includes predictive commoning and
unroll-and-jam.

Bootstrapped and tested on x86_64-unknown-linux-gnu, queued for stage1.

	PR tree-optimization/44794
	* tree-ssa-loop-manip.cc (tree_transform_and_unroll_loop):
	If an epilogue loop is required set its iteration upper bound.
---
 gcc/tree-ssa-loop-manip.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/tree-ssa-loop-manip.cc b/gcc/tree-ssa-loop-manip.cc
index 09acc1c94cc..c804a7353d5 100644
--- a/gcc/tree-ssa-loop-manip.cc
+++ b/gcc/tree-ssa-loop-manip.cc
@@ -1297,6 +1297,12 @@ tree_transform_and_unroll_loop (class loop *loop, unsigned factor,
 	}
 
       remove_path (exit);
+
+      /* The epilog loop latch executes at most factor - 1 times.
+	 Since the epilog is entered unconditionally it will need to handle
+	 up to factor executions of its body.  */
+      new_loop->any_upper_bound = 1;
+      new_loop->nb_iterations_upper_bound = factor - 1;
     }
   else
     new_exit = single_dom_exit (loop);
-- 
2.35.3

                 reply	other threads:[~2023-03-09 11:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230309111517.M4uvDz9Dsuy0MnXGRI1CbM8iAspoiiDcKiM19nrCrIs@z \
    --to=rguenther@suse.de \
    --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).