From: Richard Guenther Date: Mon, 26 Sep 2011 12:58:35 +0000 (+0000) Subject: re PR tree-optimization/50472 (Volatile qualification in data is not enough to avoid... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f8a7df459498f6e5c3308e9e3de3252dccecff9a;p=gcc.git re PR tree-optimization/50472 (Volatile qualification in data is not enough to avoid optimization over pointer to data) 2011-09-26 Richard Guenther PR tree-optimization/50472 * gimple-fold.c (fold_const_aggregate_ref_1): Do not fold volatile references. * gcc.dg/torture/pr50472.c: New testcase. From-SVN: r179196 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7b1f54d6d89..899ffe0fd1a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,11 @@ +2011-09-26 Richard Guenther + + PR tree-optimization/50472 + * gimple-fold.c (fold_const_aggregate_ref_1): Do not fold + volatile references. + 2011-09-26 Bingfeng Mei + * doc/tm.texi: Correct documentation for TARGET_ADDR_SPACE_SUBSET_P. * target.def: (addr_space_subset_p): Likewise. diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index b481c4a5fa1..d754ea9a5b9 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 35dea739f78..6caed7a6c10 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-09-26 Richard Guenther + + PR tree-optimization/50472 + * gcc.dg/torture/pr50472.c: New testcase. + 2011-09-26 Eric Botcazou * 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 index 00000000000..280f2c4ea9b --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr50472.c @@ -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" } } */