re PR rtl-optimization/35729 (const volatile variable access incorrectly hoisted...
authorZdenek Dvorak <ook@ucw.cz>
Mon, 31 Mar 2008 14:19:52 +0000 (16:19 +0200)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Mon, 31 Mar 2008 14:19:52 +0000 (14:19 +0000)
PR rtl-optimization/35729
* loop-invariant.c (check_maybe_invariant): Disallow volatile memory
references.

* gcc.dg/pr35729.c: New test.

From-SVN: r133755

gcc/ChangeLog
gcc/loop-invariant.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr35729.c [new file with mode: 0644]

index 0a426b1b849843742414ed0ce39cda9969f6b659..a78eae84de0674a2407a51d4ad73e75cb0b6749d 100644 (file)
@@ -1,3 +1,9 @@
+2008-03-31  Zdenek Dvorak  <ook@ucw.cz>
+
+       PR rtl-optimization/35729
+       * loop-invariant.c (check_maybe_invariant): Disallow volatile memory
+       references.
+
 2008-03-31  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/32000
index ba1f2888b009677bdaf01e91171d67395bcfea86..64c16a98423887ad880c24c1875f4dd8b4b93b13 100644 (file)
@@ -206,7 +206,7 @@ check_maybe_invariant (rtx x)
 
       /* Just handle the most trivial case where we load from an unchanging
         location (most importantly, pic tables).  */
-      if (MEM_READONLY_P (x))
+      if (MEM_READONLY_P (x) && !MEM_VOLATILE_P (x))
        break;
 
       return false;
index 3423800bb846adf0c9f67130c0152e3df4b49ad1..6c208d90ef9a8a264afd8a44520d1ba91d766c9a 100644 (file)
@@ -1,3 +1,8 @@
+2008-03-31  Zdenek Dvorak  <ook@ucw.cz>
+
+       PR rtl-optimization/35729
+       * gcc.dg/pr35729.c: New test.
+
 2008-03-31  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/32000
diff --git a/gcc/testsuite/gcc.dg/pr35729.c b/gcc/testsuite/gcc.dg/pr35729.c
new file mode 100644 (file)
index 0000000..3ed40f4
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-Os -fdump-rtl-loop2_invariant" } */
+
+const volatile int g_361 = 3L;
+volatile int g_2 = 0L;
+void func_1 (void)
+{
+  for (g_2 = 0; g_2 > 10; g_2++)
+    {
+      int l_357 = g_361;
+    }
+}
+
+/* { dg-final { scan-rtl-dump-times "Decided to move invariant" 0 "loop2_invariant" } } */
+/* { dg-final { cleanup-rtl-dump "loop2_invariant" } } */