re PR tree-optimization/53085 (writes to volatile struct members is missing)
authorRichard Guenther <rguenther@suse.de>
Tue, 24 Apr 2012 14:41:49 +0000 (14:41 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 24 Apr 2012 14:41:49 +0000 (14:41 +0000)
2012-04-24  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/53085
* tree-ssa-pre.c (eliminate): Do not eliminate volatile redundant
stores.

* g++.dg/torture/pr53085.C: New testcase.

From-SVN: r186764

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr53085.C [new file with mode: 0644]
gcc/tree-ssa-pre.c

index 86dc9c708a6e7361dba08f20594c9f43a3c799fd..27a67a50d91a395365aa162b4665ddb6b59aff01 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-24  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/53085
+       * tree-ssa-pre.c (eliminate): Do not eliminate volatile redundant
+       stores.
+
 2012-04-24  Richard Guenther  <rguenther@suse.de>
 
        * tree-if-conv.c (main_tree_if_conversion): Move bb under
index 9205f4299ce6c45273cd89a5b85b3250623b6620..646a150f134e9530e5bd83fcbc05aaf4b0548d8a 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-24  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/53085
+       * g++.dg/torture/pr53085.C: New testcase.
+
 2012-04-24  Andrew Pinski  <apinski@cavium.com>
 
        PR tree-opt/33512
diff --git a/gcc/testsuite/g++.dg/torture/pr53085.C b/gcc/testsuite/g++.dg/torture/pr53085.C
new file mode 100644 (file)
index 0000000..9ee29fe
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do compile }
+// { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } }
+// { dg-options "-fdump-tree-optimized" }
+
+class aa{
+    void f();
+private:
+    volatile int a;
+};
+
+void aa::f(){
+    a=1;
+    a=1;
+}
+
+// { dg-final { scan-tree-dump-times "a ={v} 1;" 2 "optimized" } }
+// { dg-final { cleanup-tree-dump "optimized" } }
index 5e6f5708ad1c3063e4e186cb1985a809feff67e7..e3e55ef48a89ec507b3e7646eb70f9391955ce23 100644 (file)
@@ -4409,6 +4409,7 @@ eliminate (void)
             has the same value number as its rhs.  If so, the store is
             dead.  */
          else if (gimple_assign_single_p (stmt)
+                  && !gimple_has_volatile_ops (stmt)
                   && !is_gimple_reg (gimple_assign_lhs (stmt))
                   && (TREE_CODE (rhs) == SSA_NAME
                       || is_gimple_min_invariant (rhs)))