From a899caf9f82767de3db556225b28dc52a81d5967 Mon Sep 17 00:00:00 2001
From: Kugan Vivekanandarajah <kugan.vivekanandarajah@linaro.org>
Date: Mon, 14 Aug 2017 10:12:09 +1000
Subject: [PATCH 1/5] add parms for rtl unroller

---
 gcc/loop-unroll.c | 24 ++++++++++++------------
 gcc/params.def    | 17 +++++++++++++++++
 2 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c
index 84145bb..871558c 100644
--- a/gcc/loop-unroll.c
+++ b/gcc/loop-unroll.c
@@ -360,13 +360,13 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
 
   /* nunroll = total number of copies of the original loop body in
      unrolled loop (i.e. if it is 2, we have to duplicate loop body once.  */
-  nunroll = PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS) / loop->ninsns;
+  nunroll = PARAM_VALUE (PARAM_MAX_UNROLLEDP_INSNS) / loop->ninsns;
   nunroll_by_av
-    = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLED_INSNS) / loop->av_ninsns;
+    = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLEDP_INSNS) / loop->av_ninsns;
   if (nunroll > nunroll_by_av)
     nunroll = nunroll_by_av;
-  if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLL_TIMES))
-    nunroll = PARAM_VALUE (PARAM_MAX_UNROLL_TIMES);
+  if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLLP_TIMES))
+    nunroll = PARAM_VALUE (PARAM_MAX_UNROLLP_TIMES);
 
   if (targetm.loop_unroll_adjust)
     nunroll = targetm.loop_unroll_adjust (nunroll, loop);
@@ -664,12 +664,12 @@ decide_unroll_runtime_iterations (struct loop *loop, int flags)
 
   /* nunroll = total number of copies of the original loop body in
      unrolled loop (i.e. if it is 2, we have to duplicate loop body once.  */
-  nunroll = PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS) / loop->ninsns;
-  nunroll_by_av = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLED_INSNS) / loop->av_ninsns;
+  nunroll = PARAM_VALUE (PARAM_MAX_UNROLLEDP_INSNS) / loop->ninsns;
+  nunroll_by_av = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLEDP_INSNS) / loop->av_ninsns;
   if (nunroll > nunroll_by_av)
     nunroll = nunroll_by_av;
-  if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLL_TIMES))
-    nunroll = PARAM_VALUE (PARAM_MAX_UNROLL_TIMES);
+  if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLLP_TIMES))
+    nunroll = PARAM_VALUE (PARAM_MAX_UNROLLP_TIMES);
 
   if (targetm.loop_unroll_adjust)
     nunroll = targetm.loop_unroll_adjust (nunroll, loop);
@@ -1158,13 +1158,13 @@ decide_unroll_stupid (struct loop *loop, int flags)
 
   /* nunroll = total number of copies of the original loop body in
      unrolled loop (i.e. if it is 2, we have to duplicate loop body once.  */
-  nunroll = PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS) / loop->ninsns;
+  nunroll = PARAM_VALUE (PARAM_MAX_UNROLLEDP_INSNS) / loop->ninsns;
   nunroll_by_av
-    = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLED_INSNS) / loop->av_ninsns;
+    = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLEDP_INSNS) / loop->av_ninsns;
   if (nunroll > nunroll_by_av)
     nunroll = nunroll_by_av;
-  if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLL_TIMES))
-    nunroll = PARAM_VALUE (PARAM_MAX_UNROLL_TIMES);
+  if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLLP_TIMES))
+    nunroll = PARAM_VALUE (PARAM_MAX_UNROLLP_TIMES);
 
   if (targetm.loop_unroll_adjust)
     nunroll = targetm.loop_unroll_adjust (nunroll, loop);
diff --git a/gcc/params.def b/gcc/params.def
index 805302b..c8b0a2b 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -302,6 +302,23 @@ DEFPARAM(PARAM_MAX_PEELED_INSNS,
 	"max-peeled-insns",
 	"The maximum number of insns of a peeled loop.",
 	100, 0, 0)
+
+DEFPARAM(PARAM_MAX_UNROLLEDP_INSNS,
+	 "max-partial-unrolled-insns",
+	 "The maximum number of instructions to consider to unroll in a loop by rtl unroller.",
+	 100, 0, 0)
+/* This parameter limits how many times the loop is unrolled depending
+   on number of insns really executed in each iteration.  */
+DEFPARAM(PARAM_MAX_AVERAGE_UNROLLEDP_INSNS,
+	 "max-partial-average-unrolled-insns",
+	 "The maximum number of instructions to consider to unroll in a loop on average by rtl unroller.",
+	 40, 0, 0)
+/* The maximum number of unrollings of a single loop.  */
+DEFPARAM(PARAM_MAX_UNROLLP_TIMES,
+	"max-partial-unroll-times",
+	"The maximum number of unrollings of a single loop by rtl unroller.",
+	4, 0, 0)
+
 /* The maximum number of peelings of a single loop.  */
 DEFPARAM(PARAM_MAX_PEEL_TIMES,
 	"max-peel-times",
-- 
2.7.4

