------- Comment #6 from rguenth at gcc dot gnu dot org  2007-07-13 12:36 -------
Basically we could just make sure to preserve TREE_THIS_VOLATILE on folded
memory references *&spinlock[0] (where the indirect reference has this flag
set, but the result from maybe_fold_offset_to_reference, spinlock[0], has not),
and properly set has_volatile_ops on array references with TREE_THIS_VOLATILE
set.  Like

Index: tree-ssa-ccp.c
===================================================================
*** tree-ssa-ccp.c      (revision 126617)
--- tree-ssa-ccp.c      (working copy)
*************** static tree
*** 1839,1844 ****
--- 1839,1845 ----
  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
*************** maybe_fold_stmt_indirect (tree expr, tre
*** 1882,1888 ****
        t = maybe_fold_offset_to_reference (base_addr, offset,
                                          TREE_TYPE (expr));
        if (t)
!       return t;
      }
    else
      {
--- 1883,1892 ----
        t = maybe_fold_offset_to_reference (base_addr, offset,
                                          TREE_TYPE (expr));
        if (t)
!       {
!         TREE_THIS_VOLATILE (t) = volatile_p;
!         return t;
!       }
      }
    else
      {
Index: tree-ssa-operands.c
===================================================================
--- tree-ssa-operands.c (revision 126617)
+++ tree-ssa-operands.c (working copy)
@@ -2078,6 +2078,9 @@ get_expr_operands (tree stmt, tree *expr

            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)
          {


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32721

Reply via email to