public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/guojiufu/heads/guojiufu-branch)] refine loop unroll heuristic.
@ 2020-06-29 4:50 Jiu Fu Guo
0 siblings, 0 replies; only message in thread
From: Jiu Fu Guo @ 2020-06-29 4:50 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8df3e68e22700ab4f24c42d1b05079e889a5da5b
commit 8df3e68e22700ab4f24c42d1b05079e889a5da5b
Author: guojiufu <guojiufu@linux.ibm.com>
Date: Mon Jun 29 12:50:11 2020 +0800
refine loop unroll heuristic.
Diff:
---
gcc/config/rs6000/rs6000.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index d62e413670a..1c5e76953ac 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -5130,11 +5130,33 @@ rs6000_destroy_cost_data (void *data)
free (data);
}
+/* Count call insns in a loop. */
+static unsigned int
+count_call_in_loop (struct loop *loop)
+{
+ basic_block *bbs;
+ rtx_insn *insn;
+ unsigned int i;
+ unsigned int call_ins_num = 0;
+
+ bbs = get_loop_body (loop);
+ for (i = 0; i < loop->num_nodes; i++)
+ FOR_BB_INSNS (bbs[i], insn)
+ if (CALL_P (insn))
+ call_ins_num++;
+
+ free (bbs);
+
+ return call_ins_num;
+}
+
/* Implement targetm.loop_unroll_adjust. */
static unsigned
rs6000_loop_unroll_adjust (unsigned nunroll, struct loop *loop)
{
+ unsigned call_num;
+
if (unroll_only_small_loops)
{
/* TODO: Hardcoded here, PARAM may be used for this. */
@@ -5142,9 +5164,17 @@ rs6000_loop_unroll_adjust (unsigned nunroll, struct loop *loop)
return MIN (4, nunroll);
if (loop->ninsns <= 10)
return MIN (2, nunroll);
+
return 0;
}
+ /* Do not unroll very complex loop. */
+ if (loop->ninsns > 10
+ && (call_num = count_call_in_loop (loop)) > 0
+ && (call_num + num_loop_branches (loop)) * 5 > loop->ninsns
+ && !single_exit (loop))
+ return 0;
+
return nunroll;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-29 4:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 4:50 [gcc(refs/users/guojiufu/heads/guojiufu-branch)] refine loop unroll heuristic Jiu Fu Guo
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).