This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, commited] PR 35729
- From: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 31 Mar 2008 16:20:26 +0200
- Subject: [patch, commited] PR 35729
Hi,
this patch prevents loop invariant motion from moving memory references
marked "const volatile" (whatever is that supposed to mean -- that you
must do the read, but you are guaranteed to get the same value each
time?) out of the loop.
Bootstrapped & regtested on i686, commited.
Zdenek
Index: ChangeLog
===================================================================
*** ChangeLog (revision 133754)
--- ChangeLog (working copy)
***************
*** 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: testsuite/gcc.dg/pr35729.c
===================================================================
*** testsuite/gcc.dg/pr35729.c (revision 0)
--- testsuite/gcc.dg/pr35729.c (revision 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" } } */
Index: testsuite/ChangeLog
===================================================================
*** testsuite/ChangeLog (revision 133754)
--- testsuite/ChangeLog (working copy)
***************
*** 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
Index: loop-invariant.c
===================================================================
*** loop-invariant.c (revision 133754)
--- loop-invariant.c (working copy)
*************** check_maybe_invariant (rtx x)
*** 206,212 ****
/* Just handle the most trivial case where we load from an unchanging
location (most importantly, pic tables). */
! if (MEM_READONLY_P (x))
break;
return false;
--- 206,212 ----
/* Just handle the most trivial case where we load from an unchanging
location (most importantly, pic tables). */
! if (MEM_READONLY_P (x) && !MEM_VOLATILE_P (x))
break;
return false;