re PR tree-optimization/32721 (CCP removes volatile qualifiers.)

2007-07-13  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/32721
	* tree-ssa-ccp.c (maybe_fold_stmt_indirect): Preserve
	TREE_THIS_VOLATILE on the folded reference.
	* tree-ssa-operands.c (get_expr_operands): Set has_volatile_ops
	if the array reference has TREE_THIS_VOLATILE set.

	* gcc.dg/pr32721.c: New testcase.

From-SVN: r126624
This commit is contained in:
Richard Guenther 2007-07-13 15:41:02 +00:00 committed by Richard Biener
parent 05724daed2
commit cbf8d355b8
5 changed files with 39 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2007-07-13 Richard Guenther <rguenther@suse.de>
PR tree-optimization/32721
* tree-ssa-ccp.c (maybe_fold_stmt_indirect): Preserve
TREE_THIS_VOLATILE on the folded reference.
* tree-ssa-operands.c (get_expr_operands): Set has_volatile_ops
if the array reference has TREE_THIS_VOLATILE set.
2007-07-13 H.J. Lu <hongjiu.lu@intel.com>
PR other/32188

View File

@ -1,3 +1,8 @@
2007-07-13 Richard Guenther <rguenther@suse.de>
PR tree-optimization/32721
* gcc.dg/pr32721.c: New testcase.
2007-07-13 Hans-Peter Nilsson <hp@axis.com>
* gcc.dg/20011127-1.c: Use dg-message, not dg-error to match the

View File

@ -0,0 +1,18 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
int spinlock[2];
int main ()
{
volatile int * spinlock0;
volatile int * spinlock1;
spinlock0 = &spinlock[0];
spinlock1 = &spinlock[1];
*spinlock0 = 0;
*spinlock1 = 0;
while (*spinlock0);
}
/* { dg-final { scan-tree-dump "= spinlock.0." "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */

View File

@ -1839,6 +1839,7 @@ static tree
maybe_fold_stmt_indirect (tree expr, tree base, tree offset)
{
tree t;
bool volatile_p = TREE_THIS_VOLATILE (expr);
/* We may well have constructed a double-nested PLUS_EXPR via multiple
substitutions. Fold that down to one. Remove NON_LVALUE_EXPRs that
@ -1882,7 +1883,10 @@ maybe_fold_stmt_indirect (tree expr, tree base, tree offset)
t = maybe_fold_offset_to_reference (base_addr, offset,
TREE_TYPE (expr));
if (t)
return t;
{
TREE_THIS_VOLATILE (t) = volatile_p;
return t;
}
}
else
{

View File

@ -2078,6 +2078,9 @@ get_expr_operands (tree stmt, tree *expr_p, int flags)
if (!none)
flags |= opf_no_vops;
if (TREE_THIS_VOLATILE (expr))
get_stmt_ann (stmt)->has_volatile_ops = true;
}
else if (TREE_CODE (ref) == INDIRECT_REF)
{