From a01b319fccabf29a461c611632cbd848c7ea2930 Mon Sep 17 00:00:00 2001
From: shivac <shivac@marvell.com>
Date: Wed, 4 May 2016 16:37:19 +0800
Subject: [PATCH 6/7] skip the loop if the loop size too small

---
 gcc/modulo-sched.c | 8 ++++++++
 gcc/params.def     | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c
index ce2c338..890b543 100644
--- a/gcc/modulo-sched.c
+++ b/gcc/modulo-sched.c
@@ -1936,6 +1936,14 @@ sms_schedule (void)
 	  continue;
 	}
 
+      if (num_loop_insns (loop) < PARAM_VALUE (PARAM_SMS_LOOP_MIN_SIZE))
+	{
+	  if (dump_file)
+	    fprintf (dump_file, "SMS loop size = %d is too small\n",
+		     num_loop_insns (loop));
+	  continue;
+	}
+
       if ((non_sms_insn = loop_sms_insn_check (loop)))
 	{
 	  if (dump_file)
diff --git a/gcc/params.def b/gcc/params.def
index 9e05401..8fa812f 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -375,6 +375,10 @@ DEFPARAM(PARAM_SMS_LOOP_AVERAGE_COUNT_THRESHOLD,
 	 "sms-loop-average-count-threshold",
 	 "A threshold on the average loop count considered by the swing modulo scheduler.",
 	 0, 0, 0)
+DEFPARAM(PARAM_SMS_LOOP_MIN_SIZE,
+	 "sms-loop-min-size",
+	 "A threshold on the loop instruction count considered by the swing modulo scheduler",
+	 8, 0, 0)
 
 DEFPARAM(HOT_BB_COUNT_WS_PERMILLE,
 	 "hot-bb-count-ws-permille",
-- 
2.5.0

