re PR rtl-optimization/35729 (const volatile variable access incorrectly hoisted out of loop)

PR rtl-optimization/35729
	* loop-invariant.c (check_maybe_invariant): Disallow volatile memory
	references.

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

From-SVN: r133755
This commit is contained in:
Zdenek Dvorak 2008-03-31 16:19:52 +02:00 committed by Zdenek Dvorak
parent 6b20c50ffe
commit 66f91b93db
4 changed files with 27 additions and 1 deletions

View 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

View 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;

View 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

View File

@ -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" } } */