+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
+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
--- /dev/null
+/* { 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" } } */
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
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
{
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)
{