]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
modulo-sched: backport PR92591 fix from mainline
authorRoman Zhuykov <zhroma@ispras.ru>
Fri, 20 Dec 2019 15:05:12 +0000 (15:05 +0000)
committerRoman Zhuykov <zhroma@gcc.gnu.org>
Fri, 20 Dec 2019 15:05:12 +0000 (15:05 +0000)
2019-12-20  Roman Zhuykov  <zhroma@ispras.ru>

modulo-sched: fix branch rescheduling issue (PR92591)

PR rtl-optimization/92591
* modulo-sched.c (ps_add_node_check_conflicts): Improve checking
for history > 0 case.
* params.def (sms-dfa-history): Limit to 16.

gcc/testsuite:

PR rtl-optimization/92591
* gcc.dg/pr92951-1.c: New test.
* gcc.dg/pr92951-2.c: New test.

From-SVN: r279642

gcc/ChangeLog
gcc/modulo-sched.c
gcc/params.def
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr92951-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr92951-2.c [new file with mode: 0644]

index e01e58d3a0a4a62e7c38f26ec4b2bc19a01f8f1f..9b5b4a0cf5b91f6c92f3c8bf54e9c5b81f5f9d5d 100644 (file)
@@ -1,3 +1,13 @@
+2019-12-20  Roman Zhuykov  <zhroma@ispras.ru>
+
+       Backport from mainline
+       2019-12-13  Roman Zhuykov  <zhroma@ispras.ru>
+
+       PR rtl-optimization/92591
+       * modulo-sched.c (ps_add_node_check_conflicts): Improve checking
+       for history > 0 case.
+       * params.def (sms-dfa-history): Limit to 16.
+
 2019-12-19  Georg-Johann Lay  <avr@gjlay.de>
 
        Backport support for some AVR devices from avrxmega3 family
index 9954ea5cfa145e5aff88a67ef0afbeb200e65ac7..059b5440123dcc79caa84a8ca29e06b8c0e26f41 100644 (file)
@@ -3201,7 +3201,7 @@ ps_add_node_check_conflicts (partial_schedule_ptr ps, int n,
                             int c, sbitmap must_precede,
                             sbitmap must_follow)
 {
-  int has_conflicts = 0;
+  int i, first, amount, has_conflicts = 0;
   ps_insn_ptr ps_i;
 
   /* First add the node to the PS, if this succeeds check for
@@ -3209,23 +3209,32 @@ ps_add_node_check_conflicts (partial_schedule_ptr ps, int n,
   if (! (ps_i = add_node_to_ps (ps, n, c, must_precede, must_follow)))
     return NULL; /* Failed to insert the node at the given cycle.  */
 
-  has_conflicts = ps_has_conflicts (ps, c, c)
-                 || (ps->history > 0
-                     && ps_has_conflicts (ps,
-                                          c - ps->history,
-                                          c + ps->history));
-
-  /* Try different issue slots to find one that the given node can be
-     scheduled in without conflicts.  */
-  while (has_conflicts)
+  while (1)
     {
+      has_conflicts = ps_has_conflicts (ps, c, c);
+      if (ps->history > 0 && !has_conflicts)
+       {
+         /* Check all 2h+1 intervals, starting from c-2h..c up to c..2h,
+            but not more than ii intervals.  */
+         first = c - ps->history;
+         amount = 2 * ps->history + 1;
+         if (amount > ps->ii)
+           amount = ps->ii;
+         for (i = first; i < first + amount; i++)
+           {
+             has_conflicts = ps_has_conflicts (ps,
+                                               i - ps->history,
+                                               i + ps->history);
+             if (has_conflicts)
+               break;
+           }
+       }
+      if (!has_conflicts)
+       break;
+      /* Try different issue slots to find one that the given node can be
+        scheduled in without conflicts.  */
       if (! ps_insn_advance_column (ps, ps_i, must_follow))
        break;
-      has_conflicts = ps_has_conflicts (ps, c, c)
-                     || (ps->history > 0
-                         && ps_has_conflicts (ps,
-                                              c - ps->history,
-                                              c + ps->history));
     }
 
   if (has_conflicts)
index 813dc55d94c61a788d244bb12290f7309964fbc7..8e4887e50a2f040bc7926f96be3a97fe37bc2c5a 100644 (file)
@@ -419,7 +419,7 @@ DEFPARAM(PARAM_SMS_MIN_SC,
 DEFPARAM(PARAM_SMS_DFA_HISTORY,
         "sms-dfa-history",
         "The number of cycles the swing modulo scheduler considers when checking conflicts using DFA.",
-        0, 0, 0)
+        0, 0, 16)
 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.",
index dcee8381c861d00c082dfe68f061c620abc310a5..2b340a38ff2776e2e6ad6465ae3b4de36cc23e84 100644 (file)
@@ -1,3 +1,12 @@
+2019-12-20  Roman Zhuykov  <zhroma@ispras.ru>
+
+       Backport from mainline
+       2019-12-13  Roman Zhuykov  <zhroma@ispras.ru>
+
+       PR rtl-optimization/92591
+       * gcc.dg/pr92951-1.c: New test.
+       * gcc.dg/pr92951-2.c: New test.
+
 2019-12-17  Andreas Krebbel  <krebbel@linux.ibm.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.dg/pr92951-1.c b/gcc/testsuite/gcc.dg/pr92951-1.c
new file mode 100644 (file)
index 0000000..0f9365d
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR rtl-optimization/92591 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fmodulo-sched -fweb -fno-dce -fno-ivopts -fno-sched-pressure -fno-tree-loop-distribute-patterns --param sms-dfa-history=1" } */
+/* { dg-additional-options "-mcpu=e500mc" { target { powerpc-*-* } } } */
+
+void
+wf (char *mr, int tc)
+{
+  while (tc-- > 0)
+    *mr++ = 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr92951-2.c b/gcc/testsuite/gcc.dg/pr92951-2.c
new file mode 100644 (file)
index 0000000..04a8092
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR rtl-optimization/92591 */
+/* { dg-do compile } */
+/* { dg-options "-Os -fmodulo-sched -fmodulo-sched-allow-regmoves --param sms-dfa-history=8" } */
+
+#include "../gcc.c-torture/execute/pr61682.c"