PR rtl-optimization/pr55153
authorVladimir Makarov <vmakarov@redhat.com>
Tue, 15 Jan 2013 16:47:36 +0000 (16:47 +0000)
committerVladimir Makarov <vmakarov@gcc.gnu.org>
Tue, 15 Jan 2013 16:47:36 +0000 (16:47 +0000)
2013-01-15  Vladimir Makarov  <vmakarov@redhat.com>

PR rtl-optimization/pr55153
* sched-deps.c (sched_analyze_2): Add pending reads for prefetch.

2013-01-15  Vladimir Makarov  <vmakarov@redhat.com>

PR rtl-optimization/pr55153
* gcc.dg/pr55153.c: New.

From-SVN: r195211

gcc/ChangeLog
gcc/sched-deps.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr55153.c [new file with mode: 0644]

index 15b15032d8b595e1a26350cbd09b71ede07bd8dd..75efa7a216df3d7aba02ce5b4cd8eb49318e45cd 100644 (file)
@@ -1,3 +1,8 @@
+2013-01-15  Vladimir Makarov  <vmakarov@redhat.com>
+
+       PR rtl-optimization/pr55153
+       * sched-deps.c (sched_analyze_2): Add pending reads for prefetch.
+
 2013-01-15  Martin Jambor  <mjambor@suse.cz>
 
        PR tree-optimization/55920
index f61e837847fabc8d6760792d3dcfb594af76e79c..3f37aa026c92ce9c01bc603c09f75f0d4bab9901 100644 (file)
@@ -2707,6 +2707,20 @@ sched_analyze_2 (struct deps_desc *deps, rtx x, rtx insn)
     case PREFETCH:
       if (PREFETCH_SCHEDULE_BARRIER_P (x))
        reg_pending_barrier = TRUE_BARRIER;
+      /* Prefetch insn contains addresses only.  So if the prefetch
+        address has no registers, there will be no dependencies on
+        the prefetch insn.  This is wrong with result code
+        correctness point of view as such prefetch can be moved below
+        a jump insn which usually generates MOVE_BARRIER preventing
+        to move insns containing registers or memories through the
+        barrier.  It is also wrong with generated code performance
+        point of view as prefetch withouth dependecies will have a
+        tendency to be issued later instead of earlier.  It is hard
+        to generate accurate dependencies for prefetch insns as
+        prefetch has only the start address but it is better to have
+        something than nothing.  */
+      add_insn_mem_dependence (deps, true, insn,
+                              gen_rtx_MEM (Pmode, XEXP (PATTERN (insn), 0)));
       break;
 
     case UNSPEC_VOLATILE:
index c20ed625e95323a26855613d5577e747bacda23d..340bbcecd8e1d2b37e2b89972c59bdc6ebba64c4 100644 (file)
@@ -1,3 +1,8 @@
+2013-01-15  Vladimir Makarov  <vmakarov@redhat.com>
+
+       PR rtl-optimization/pr55153
+       * gcc.dg/pr55153.c: New.
+
 2013-01-15  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/55920
diff --git a/gcc/testsuite/gcc.dg/pr55153.c b/gcc/testsuite/gcc.dg/pr55153.c
new file mode 100644 (file)
index 0000000..86e9970
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR tree-optimization/55153 */
+/* { dg-do compile } */
+/* { dg-options "-O -fsched2-use-superblocks -fschedule-insns2" } */
+
+extern int a[];
+
+void
+foo (void)
+{
+  __builtin_prefetch (a, 0, 0);
+}