Commit 06baaba3 by Richard Guenther Committed by Richard Biener

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
parent 64e0f5ff
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> 2010-09-20 Jan Hubicka <jh@suse.cz>
PR tree-optimize/45605 PR tree-optimize/45605
......
...@@ -4200,9 +4200,18 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, ...@@ -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 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 a const reference, and if "x" is a TARGET_EXPR we want
to take advantage of the optimization below. */ 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)); tree t = gimple_fold_indirect_ref_rhs (TREE_OPERAND (*from_p, 0));
if (t) 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; *from_p = t;
ret = GS_OK; ret = GS_OK;
changed = true; changed = true;
......
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> 2010-09-20 Jan Hubicka <jh@suse.cz>
PR tree-optimize/45605 PR tree-optimize/45605
......
/* { 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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment