re PR middle-end/49671 (volatile goes missing after inlining)
authorAndrew Pinski <apinski@cavium.com>
Tue, 26 Jul 2011 05:28:45 +0000 (05:28 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Tue, 26 Jul 2011 05:28:45 +0000 (22:28 -0700)
2011-07-25  Andrew Pinski  <apinski@cavium.com>

PR tree-opt/49671
* tree-inline.c (remap_gimple_op_r): Copy TREE_THIS_VOLATILE and
TREE_THIS_NOTRAP into the inner most MEM_REF.
Always copy TREE_THIS_VOLATILE.
* tree-sra.c (ptr_parm_has_direct_uses): Check that the lhs, rhs and
arguments are not volatile references.

2011-07-25  Andrew Pinski  <apinski@cavium.com>

PR tree-opt/49671
* gcc.dg/tree-ssa/pr49671-1.c: New testcase.
* gcc.dg/tree-ssa/pr49671-2.c: New testcase.

From-SVN: r176782

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr49671-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr49671-2.c [new file with mode: 0644]
gcc/tree-inline.c
gcc/tree-sra.c

index b2ed72a61b3da729ce32360d48400591b41a265d..c93e5e3890ed81274694d52bc7e61178c4806cc8 100644 (file)
@@ -1,3 +1,12 @@
+2011-07-25  Andrew Pinski  <apinski@cavium.com>
+
+       PR tree-opt/49671
+       * tree-inline.c (remap_gimple_op_r): Copy TREE_THIS_VOLATILE and
+       TREE_THIS_NOTRAP into the inner most MEM_REF.
+       Always copy TREE_THIS_VOLATILE.
+       * tree-sra.c (ptr_parm_has_direct_uses): Check that the lhs, rhs and
+       arguments are not volatile references.
+
 2011-07-25  Richard Henderson  <rth@redhat.com>
 
        * insn-notes.def (NOTE_INSN_CFA_RESTORE_STATE): Remove.
index b90356962f8a8b2ec791b86c2bd2a41073a5d4a0..dcaab8777011dd6d63d8abb33d04537caac4ad45 100644 (file)
@@ -1,3 +1,9 @@
+2011-07-25  Andrew Pinski  <apinski@cavium.com>
+
+       PR tree-opt/49671
+       * gcc.dg/tree-ssa/pr49671-1.c: New testcase.
+       * gcc.dg/tree-ssa/pr49671-2.c: New testcase.
+       
 2011-07-25  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * lib/target-supports.exp (check_effective_target_mmap): New proc.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr49671-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr49671-1.c
new file mode 100644 (file)
index 0000000..acc9980
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" }  */
+volatile int t;
+static inline int cvmx_atomic_get32(volatile int *ptr)
+{
+    return *ptr;
+}
+void f(void)
+{
+  while (!cvmx_atomic_get32(&t))
+    ;
+}
+
+/* { dg-final { scan-tree-dump "\{v\}" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr49671-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr49671-2.c
new file mode 100644 (file)
index 0000000..ba5a9d9
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" }  */
+int t;
+static inline int cvmx_atomic_get32(int *ptr)
+{
+    return *(volatile int*)ptr;
+}
+void f(void)
+{
+  while (!cvmx_atomic_get32(&t))
+    ;
+}
+
+/* { dg-final { scan-tree-dump "\{v\}" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
+
index 6a8eae8694507cac0be500d98a857054326fea11..e9daff63cc351045a3b9487cdc6fbd7fddc3acbb 100644 (file)
@@ -881,14 +881,16 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data)
                              build_int_cst
                              (TREE_TYPE (TREE_OPERAND (*tp, 1)), 0));
              *tp = tem;
+             TREE_THIS_VOLATILE (*tem_basep) = TREE_THIS_VOLATILE (old);
+             TREE_THIS_NOTRAP (*tem_basep) = TREE_THIS_NOTRAP (old);
            }
          else
            {
              *tp = fold_build2 (MEM_REF, type,
                                 ptr, TREE_OPERAND (*tp, 1));
-             TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old);
              TREE_THIS_NOTRAP (*tp) = TREE_THIS_NOTRAP (old);
            }
+         TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old);
          TREE_NO_WARNING (*tp) = TREE_NO_WARNING (old);
          *walk_subtrees = 0;
          return NULL;
index 6f784ee6489b776b02198aecbc95c42fccfdaf9b..cbebb81ba02dc78959d5572dd3466c9d34de3f86 100644 (file)
@@ -3302,7 +3302,8 @@ ptr_parm_has_direct_uses (tree parm)
              && TREE_OPERAND (lhs, 0) == name
              && integer_zerop (TREE_OPERAND (lhs, 1))
              && types_compatible_p (TREE_TYPE (lhs),
-                                    TREE_TYPE (TREE_TYPE (name))))
+                                    TREE_TYPE (TREE_TYPE (name)))
+             && !TREE_THIS_VOLATILE (lhs))
            uses_ok++;
        }
       if (gimple_assign_single_p (stmt))
@@ -3314,7 +3315,8 @@ ptr_parm_has_direct_uses (tree parm)
              && TREE_OPERAND (rhs, 0) == name
              && integer_zerop (TREE_OPERAND (rhs, 1))
              && types_compatible_p (TREE_TYPE (rhs),
-                                    TREE_TYPE (TREE_TYPE (name))))
+                                    TREE_TYPE (TREE_TYPE (name)))
+             && !TREE_THIS_VOLATILE (rhs))
            uses_ok++;
        }
       else if (is_gimple_call (stmt))
@@ -3329,7 +3331,8 @@ ptr_parm_has_direct_uses (tree parm)
                  && TREE_OPERAND (arg, 0) == name
                  && integer_zerop (TREE_OPERAND (arg, 1))
                  && types_compatible_p (TREE_TYPE (arg),
-                                        TREE_TYPE (TREE_TYPE (name))))
+                                        TREE_TYPE (TREE_TYPE (name)))
+                 && !TREE_THIS_VOLATILE (arg))
                uses_ok++;
            }
        }