OSDN Git Service

Backported from mainline
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Feb 2013 14:16:20 +0000 (14:16 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Feb 2013 14:16:20 +0000 (14:16 +0000)
2013-01-25  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/56098
* tree-ssa-phiopt.c (nt_init_block): Don't call add_or_mark_expr
for stmts with volatile ops.
(cond_store_replacement): Don't optimize if assign has volatile ops.
(cond_if_else_store_replacement_1): Don't optimize if either
then_assign or else_assign have volatile ops.

* gcc.dg/pr56098-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@195663 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr56098-1.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.c

index f3b717f..a45df1f 100644 (file)
@@ -1,6 +1,15 @@
 2013-02-01  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-01-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/56098
+       * tree-ssa-phiopt.c (nt_init_block): Don't call add_or_mark_expr
+       for stmts with volatile ops.
+       (cond_store_replacement): Don't optimize if assign has volatile ops.
+       (cond_if_else_store_replacement_1): Don't optimize if either
+       then_assign or else_assign have volatile ops.
+
        2013-01-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/49069
index c7903fa..6726169 100644 (file)
@@ -1,6 +1,11 @@
 2013-02-01  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-01-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/56098
+       * gcc.dg/pr56098-1.c: New test.
+
        2013-01-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/56052
diff --git a/gcc/testsuite/gcc.dg/pr56098-1.c b/gcc/testsuite/gcc.dg/pr56098-1.c
new file mode 100644 (file)
index 0000000..c3b081a
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR tree-optimization/56098 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+volatile int *p;
+
+void
+foo (int x)
+{
+  *p = 1;
+  if (x)
+    *p = 2;
+}
+
+/* { dg-final { scan-tree-dump-not "=\[^\n\r]*\\*p" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
index d4019c0..8b90469 100644 (file)
@@ -1232,7 +1232,7 @@ nt_init_block (struct dom_walk_data *data ATTRIBUTE_UNUSED, basic_block bb)
     {
       gimple stmt = gsi_stmt (gsi);
 
-      if (gimple_assign_single_p (stmt))
+      if (gimple_assign_single_p (stmt) && !gimple_has_volatile_ops (stmt))
        {
          add_or_mark_expr (bb, gimple_assign_lhs (stmt), nontrap_set, true);
          add_or_mark_expr (bb, gimple_assign_rhs1 (stmt), nontrap_set, false);
@@ -1309,7 +1309,8 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb,
 
   /* Check if middle_bb contains of only one store.  */
   if (!assign
-      || !gimple_assign_single_p (assign))
+      || !gimple_assign_single_p (assign)
+      || gimple_has_volatile_ops (assign))
     return false;
 
   locus = gimple_location (assign);
@@ -1386,9 +1387,11 @@ cond_if_else_store_replacement_1 (basic_block then_bb, basic_block else_bb,
   if (then_assign == NULL
       || !gimple_assign_single_p (then_assign)
       || gimple_clobber_p (then_assign)
+      || gimple_has_volatile_ops (then_assign)
       || else_assign == NULL
       || !gimple_assign_single_p (else_assign)
-      || gimple_clobber_p (else_assign))
+      || gimple_clobber_p (else_assign)
+      || gimple_has_volatile_ops (else_assign))
     return false;
 
   lhs = gimple_assign_lhs (then_assign);