aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2010-09-20 15:54:03 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2010-09-20 15:54:03 +0000
commit06baaba377b39dbc49f3dcd8289df5d0657a01c4 (patch)
tree889547809b1062951c7b4d333495f6c88dad4420 /gcc/gimplify.c
parent64e0f5ff1f3be1ddccc2a50cb371b5dce94124b1 (diff)
downloadgcc-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/gimplify.c')
-rw-r--r--gcc/gimplify.c9
1 files changed, 9 insertions, 0 deletions
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;