Commit 3a2df831 by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/47391 (read from const volatile incorrectly eliminated)

	PR tree-optimization/47391
	* varpool.c (const_value_known_p): Return false if
	decl is volatile.

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

From-SVN: r169084
parent d8debb1d
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
* tree-ssa-live.c (remove_unused_scope_block_p): Don't remove * tree-ssa-live.c (remove_unused_scope_block_p): Don't remove
DECL_IGNORED_P non-reg vars if they are used. DECL_IGNORED_P non-reg vars if they are used.
PR tree-optimization/47391
* varpool.c (const_value_known_p): Return false if
decl is volatile.
2011-01-21 Kai Tietz <kai.tietz@onevision.com> 2011-01-21 Kai Tietz <kai.tietz@onevision.com>
PR bootstrap/47215 PR bootstrap/47215
......
2011-01-21 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/47391
* gcc.dg/pr47391.c: New test.
2011-01-21 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2011-01-21 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* g++.dg/template/char1.C: Use signed char. * g++.dg/template/char1.C: Use signed char.
......
/* PR tree-optimization/47391 */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
const volatile int v = 1;
int i = 0;
void
foo (void)
{
i = v;
}
int
main (void)
{
foo ();
return 0;
}
/* { dg-final { scan-tree-dump-not "i = 1;" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
/* Callgraph handling code. /* Callgraph handling code.
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by Jan Hubicka Contributed by Jan Hubicka
...@@ -370,7 +370,7 @@ const_value_known_p (tree decl) ...@@ -370,7 +370,7 @@ const_value_known_p (tree decl)
gcc_assert (TREE_CODE (decl) == VAR_DECL); gcc_assert (TREE_CODE (decl) == VAR_DECL);
if (!TREE_READONLY (decl)) if (!TREE_READONLY (decl) || TREE_THIS_VOLATILE (decl))
return false; return false;
/* Gimplifier takes away constructors of local vars */ /* Gimplifier takes away constructors of local vars */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment