]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/63347 (m68k misoptimisation with -fschedule-insns)
authorJeff Law <law@redhat.com>
Wed, 13 Jan 2016 22:55:31 +0000 (15:55 -0700)
committerJeff Law <law@gcc.gnu.org>
Wed, 13 Jan 2016 22:55:31 +0000 (15:55 -0700)
PR target/63347
* haifa-sched.c (prune_ready_list): If we have a SCHED_GROUP_P insn
that needs to be queued, just queue it for a single cycle.

PR target/63347
* gcc.target/m68k/pr63347.c: New test.

From-SVN: r232354

gcc/ChangeLog
gcc/haifa-sched.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/m68k/pr63347.c [new file with mode: 0644]

index c8221e44cd1e053b186e2bb33f51587cfc9812d9..305392cacc2da46411f4eed2927413ac67c3e914 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-12  Jeff Law  <law@redhat.com>
+
+       PR target/63347
+       * haifa-sched.c (prune_ready_list): If we have a SCHED_GROUP_P insn
+       that needs to be queued, just queue it for a single cycle.
+
 2016-01-12  Renlin Li  <renlin.li@arm.com>
 
        PR target/69082
index e437e0a429cc5315c432009570a5c1a2f1496e24..113076968beddbb10591be39ccf64466cceb5134 100644 (file)
@@ -5801,7 +5801,15 @@ prune_ready_list (state_t temp_state, bool first_cycle_insn_p,
              if (SCHED_GROUP_P (insn) && cost > min_cost_group)
                min_cost_group = cost;
              ready_remove (&ready, i);
-             queue_insn (insn, cost, reason);
+             /* Normally we'd want to queue INSN for COST cycles.  However,
+                if SCHED_GROUP_P is set, then we must ensure that nothing
+                else comes between INSN and its predecessor.  If there is
+                some other insn ready to fire on the next cycle, then that
+                invariant would be broken.
+
+                So when SCHED_GROUP_P is set, just queue this insn for a
+                single cycle.  */
+             queue_insn (insn, SCHED_GROUP_P (insn) ? 1 : cost, reason);
              if (i + 1 < n)
                break;
            }
index fd5de3e05f7dad89210bad109e5b3650eaa2ecf9..c6fb9be7951269ed1eb7462f3ff89fafcae1d4e9 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-12  Jeff Law  <law@redhat.com>
+
+       PR target/63347
+       * gcc.target/m68k/pr63347.c: New test.
+
 2016-01-12  James Greenhalgh  <james.greenhalgh@arm.com>
 
        Backport from mainline.
diff --git a/gcc/testsuite/gcc.target/m68k/pr63347.c b/gcc/testsuite/gcc.target/m68k/pr63347.c
new file mode 100644 (file)
index 0000000..1d23e9a
--- /dev/null
@@ -0,0 +1,46 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcpu=5208" } */
+
+#include <stdlib.h>
+
+void __attribute__ ((noinline))
+oof()
+{
+  asm volatile ("" ::: "memory");
+}
+int print_info(unsigned int *ip_addr)
+{
+    int invalid = 0;
+
+    if (ip_addr) {
+        unsigned int haddr = *ip_addr;
+        oof("stuff");
+        if (0x0 == haddr) {
+            invalid = 1;
+        }
+        oof("stuff2");
+    } else {
+        invalid = 1;
+    }
+
+    return invalid;
+}
+
+int main(int argc, char *argv[])
+{
+    unsigned int myaddr;
+    int ret;
+
+    myaddr = 0x0;
+    ret = print_info(&myaddr);
+    if (!ret)
+        abort ();
+
+    myaddr = 0x01020304;
+    ret = print_info(&myaddr);
+    if (ret)
+        abort ();
+    exit (0);
+}
+
+