diff options
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr49671-1.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr49671-2.c | 17 | ||||
-rw-r--r-- | gcc/tree-inline.c | 4 | ||||
-rw-r--r-- | gcc/tree-sra.c | 9 |
6 files changed, 58 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b2ed72a..c93e5e3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b903569..dcaab87 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..acc9980 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr49671-1.c @@ -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 index 0000000..ba5a9d9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr49671-2.c @@ -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" } } */ + + diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 6a8eae8..e9daff6 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -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; diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 6f784ee..cbebb81 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -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++; } } |