re PR tree-optimization/27236 (inliner creates an INDIRECT_REF without TREE_THIS_VOLA...
authorAndrew Pinski <pinskia@gcc.gnu.org>
Mon, 24 Apr 2006 09:06:51 +0000 (02:06 -0700)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 24 Apr 2006 09:06:51 +0000 (09:06 +0000)
2006-04-24  Andrew Pinski  <pinskia@gcc.gnu.org>
Richard Guenther  <rguenther@suse.de>

PR tree-optimization/27236
* tree-inline.c (copy_body_r): Make sure to copy
TREE_THIS_VOLATILE flag.

* gcc.dg/tree-ssa/pr27236.c: New testcase.

Co-Authored-By: Richard Guenther <rguenther@suse.de>
From-SVN: r113221

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

index 171808d73cd6c51146980b44275e821f988028b0..51d8065086b9f26e448aa67fc8994229307b09d7 100644 (file)
@@ -1,3 +1,10 @@
+2006-04-24  Andrew Pinski  <pinskia@gcc.gnu.org>
+       Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/27236
+       * tree-inline.c (copy_body_r): Make sure to copy
+       TREE_THIS_VOLATILE flag.
+
 2006-04-24  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/26869
index f477f4b89c1ba05cf7d61e544f2716a1fc44580b..e6096c11bfe73b9cbace32d4a87be873b3f8311d 100644 (file)
@@ -1,3 +1,9 @@
+2006-04-24  Andrew Pinski  <pinskia@gcc.gnu.org>
+       Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/27236
+       * gcc.dg/tree-ssa/pr27236.c: New testcase.
+
 2006-04-24  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/19963
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr27236.c b/gcc/testsuite/gcc.dg/tree-ssa/pr27236.c
new file mode 100644 (file)
index 0000000..b623486
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+static inline int inline_read(volatile int *mem)
+{
+        return *mem;
+}
+int foo_read(volatile int *mem)
+{
+        return inline_read(mem);
+}
+unsigned int foo(volatile int *mem)
+{
+        foo_read(mem);
+        return foo_read(mem);
+}
+
+/* { dg-final { scan-tree-dump-times "foo_read" 5 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
index 6eb890b0ea288b62e93f05bf300dd18f48ec9749..309bb406fb8ed320965e74c2ee2275734655ae24 100644 (file)
@@ -590,6 +590,7 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data)
          if (n)
            {
              tree new;
+             tree old;
              /* If we happen to get an ADDR_EXPR in n->value, strip
                 it manually here as we'll eventually get ADDR_EXPRs
                 which lie about their types pointed to.  In this case
@@ -598,13 +599,17 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data)
                 does other useful transformations, try that first, though.  */
              tree type = TREE_TYPE (TREE_TYPE ((tree)n->value));
              new = unshare_expr ((tree)n->value);
+             old = *tp;
              *tp = fold_indirect_ref_1 (type, new);
              if (! *tp)
                {
                  if (TREE_CODE (new) == ADDR_EXPR)
                    *tp = TREE_OPERAND (new, 0);
                  else
-                   *tp = build1 (INDIRECT_REF, type, new);
+                   {
+                     *tp = build1 (INDIRECT_REF, type, new);
+                     TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old);
+                   }
                }
              *walk_subtrees = 0;
              return NULL;