diff options
author | Richard Guenther <rguenther@suse.de> | 2010-09-20 15:54:03 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-09-20 15:54:03 +0000 |
commit | 06baaba377b39dbc49f3dcd8289df5d0657a01c4 (patch) | |
tree | 889547809b1062951c7b4d333495f6c88dad4420 /gcc | |
parent | 64e0f5ff1f3be1ddccc2a50cb371b5dce94124b1 (diff) | |
download | gcc-06baaba377b39dbc49f3dcd8289df5d0657a01c4.zip gcc-06baaba377b39dbc49f3dcd8289df5d0657a01c4.tar.gz gcc-06baaba377b39dbc49f3dcd8289df5d0657a01c4.tar.bz2 |
re PR tree-optimization/45704 (load byte instruction is used for volatile int)
2010-09-20 Richard Guenther <rguenther@suse.de>
PR middle-end/45704
* gimplify.c (gimplify_modify_expr_rhs): Preserve volatileness.
* gcc.dg/torture/pr45704.c: New testcase.
From-SVN: r164439
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/gimplify.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr45704.c | 15 |
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bb6ade7..9f4eacc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2010-09-20 Richard Guenther <rguenther@suse.de> + + PR middle-end/45704 + * gimplify.c (gimplify_modify_expr_rhs): Preserve volatileness. + 2010-09-20 Jan Hubicka <jh@suse.cz> PR tree-optimize/45605 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index e5b011a..4e6a037 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -4200,9 +4200,18 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, This kind of code arises in C++ when an object is bound to a const reference, and if "x" is a TARGET_EXPR we want to take advantage of the optimization below. */ + bool volatile_p = TREE_THIS_VOLATILE (*from_p); tree t = gimple_fold_indirect_ref_rhs (TREE_OPERAND (*from_p, 0)); if (t) { + if (TREE_THIS_VOLATILE (t) != volatile_p) + { + if (TREE_CODE_CLASS (TREE_CODE (t)) == tcc_declaration) + t = build_simple_mem_ref_loc (EXPR_LOCATION (*from_p), + build_fold_addr_expr (t)); + if (REFERENCE_CLASS_P (t)) + TREE_THIS_VOLATILE (t) = volatile_p; + } *from_p = t; ret = GS_OK; changed = true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3d98cd9..6dac3e5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-09-20 Richard Guenther <rguenther@suse.de> + + PR middle-end/45704 + * gcc.dg/torture/pr45704.c: New testcase. + 2010-09-20 Jan Hubicka <jh@suse.cz> PR tree-optimize/45605 diff --git a/gcc/testsuite/gcc.dg/torture/pr45704.c b/gcc/testsuite/gcc.dg/torture/pr45704.c new file mode 100644 index 0000000..487b30a --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr45704.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-optimized" } */ + +struct st { + int ptr; +}; + +int foo(struct st *st) +{ + int v = *(volatile int *)&st->ptr; + return v & 0xff; +} + +/* { dg-final { scan-tree-dump-times "={v}" 1 "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ |