re PR tree-optimization/46217 (store to volatile is removed)
authorRichard Guenther <rguenther@suse.de>
Wed, 3 Nov 2010 11:05:39 +0000 (11:05 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 3 Nov 2010 11:05:39 +0000 (11:05 +0000)
2010-11-03  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/46217
* tree-ssa.c (non_rewritable_mem_ref_base): Check if volatile
flag matches.
(execute_update_addresses_taken): Likewise.

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

From-SVN: r166239

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

index 1286395..76ebd7e 100644 (file)
@@ -1,3 +1,10 @@
+2010-11-03  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46217
+       * tree-ssa.c (non_rewritable_mem_ref_base): Check if volatile
+       flag matches.
+       (execute_update_addresses_taken): Likewise.
+
 2010-11-03  Joern Rennecke  <joern.rennecke@embecosm.com>
 
        PR bootstrap/44335
index a8851e4..86ff763 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-03  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46217
+       * gcc.dg/pr46217.c: New testcase.
+
 2010-11-03  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * objc.dg/property/dotsyntax-1.m: New.
diff --git a/gcc/testsuite/gcc.dg/pr46217.c b/gcc/testsuite/gcc.dg/pr46217.c
new file mode 100644 (file)
index 0000000..bb445bb
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-optimized" } */
+
+int foo(int a)
+{
+  int t;
+  *(volatile int *)&t = a;
+}
+
+/* { dg-final { scan-tree-dump "={v}" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
index 60abc6b..ca51c66 100644 (file)
@@ -1877,7 +1877,8 @@ non_rewritable_mem_ref_base (tree ref)
       if (DECL_P (decl)
          && (!integer_zerop (TREE_OPERAND (base, 1))
              || (DECL_SIZE (decl)
-                 != TYPE_SIZE (TREE_TYPE (base)))))
+                 != TYPE_SIZE (TREE_TYPE (base)))
+             || TREE_THIS_VOLATILE (decl) != TREE_THIS_VOLATILE (base)))
        return decl;
     }
 
@@ -1993,7 +1994,9 @@ execute_update_addresses_taken (void)
                      if (DECL_P (decl)
                          && (!integer_zerop (TREE_OPERAND (lhs, 1))
                              || (DECL_SIZE (decl)
-                                 != TYPE_SIZE (TREE_TYPE (orig_lhs)))))
+                                 != TYPE_SIZE (TREE_TYPE (orig_lhs)))
+                             || (TREE_THIS_VOLATILE (lhs)
+                                 != TREE_THIS_VOLATILE (decl))))
                        bitmap_set_bit (not_reg_needs, DECL_UID (decl));
                    }
                 }
@@ -2040,7 +2043,9 @@ execute_update_addresses_taken (void)
                          if (DECL_P (decl)
                              && (!integer_zerop (TREE_OPERAND (lhs, 1))
                                  || (TYPE_MAIN_VARIANT (TREE_TYPE (decl))
-                                     != TYPE_MAIN_VARIANT (TREE_TYPE (orig_lhs)))))
+                                     != TYPE_MAIN_VARIANT (TREE_TYPE (orig_lhs)))
+                                 || (TREE_THIS_VOLATILE (lhs)
+                                     != TREE_THIS_VOLATILE (decl))))
                            bitmap_set_bit (not_reg_needs, DECL_UID (decl));
                        }
                    }