OSDN Git Service

2011-09-26 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Sep 2011 12:58:35 +0000 (12:58 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Sep 2011 12:58:35 +0000 (12:58 +0000)
PR tree-optimization/50472
* gimple-fold.c (fold_const_aggregate_ref_1): Do not fold
volatile references.

* gcc.dg/torture/pr50472.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179196 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr50472.c [new file with mode: 0644]

index 7b1f54d..899ffe0 100644 (file)
@@ -1,4 +1,11 @@
+2011-09-26  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/50472
+       * gimple-fold.c (fold_const_aggregate_ref_1): Do not fold
+       volatile references.
+
 2011-09-26  Bingfeng Mei <bmei@broadcom.com>
+
        * doc/tm.texi: Correct documentation for TARGET_ADDR_SPACE_SUBSET_P.
        * target.def: (addr_space_subset_p): Likewise.
 
index b481c4a..d754ea9 100644 (file)
@@ -2919,6 +2919,9 @@ fold_const_aggregate_ref_1 (tree t, tree (*valueize) (tree))
   HOST_WIDE_INT offset, size, max_size;
   tree tem;
 
+  if (TREE_THIS_VOLATILE (t))
+    return NULL_TREE;
+
   if (TREE_CODE_CLASS (TREE_CODE (t)) == tcc_declaration)
     return get_symbol_constant_value (t);
 
index 35dea73..6caed7a 100644 (file)
@@ -1,3 +1,8 @@
+2011-09-26  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/50472
+       * gcc.dg/torture/pr50472.c: New testcase.
+
 2011-09-26  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/opt22.adb: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr50472.c b/gcc/testsuite/gcc.dg/torture/pr50472.c
new file mode 100644 (file)
index 0000000..280f2c4
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-optimized" } */
+
+static const unsigned int foo = 1;
+unsigned int test( void )
+{
+  const volatile unsigned int *bar = &foo;
+  return ( *bar );
+}
+
+/* { dg-final { scan-tree-dump-not "return 1" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */