tree.h (maybe_fold_offset_to_component_ref): Declare.

* tree.h (maybe_fold_offset_to_component_ref): Declare.
	* tree-ssa-ccp.c (maybe_fold_offset_to_component_ref): Export.
	* fold-const.c (fold_unary): Use it.

	* gcc.dg/tree-ssa/foldaddr-2.c: New file.

From-SVN: r123664
This commit is contained in:
Jan Hubicka 2007-04-09 00:12:21 +02:00 committed by Jan Hubicka
parent 136cdb2250
commit c586d32a1e
6 changed files with 33 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2007-04-08 Jan Hubicka <jh@suse.cz>
* tree.h (maybe_fold_offset_to_component_ref): Declare.
* tree-ssa-ccp.c (maybe_fold_offset_to_component_ref): Export.
* fold-const.c (fold_unary): Use it.
2007-04-08 Andrew Pinski <andrew_pinski@playstation.sony.com>
* varasm.c (assemble_variable): Remove call to

View file

@ -7735,6 +7735,13 @@ fold_unary (enum tree_code code, tree type, tree op0)
return fold_convert (type, build_fold_addr_expr (base));
}
/* Convert (type *)&A into &A->field_of_type_and_offset_0. */
if (TREE_CODE (op0) == ADDR_EXPR && POINTER_TYPE_P (type)
&& (tem = maybe_fold_offset_to_component_ref
(TREE_TYPE (TREE_OPERAND (op0, 0)), TREE_OPERAND (op0, 0),
integer_zero_node, TREE_TYPE (type), false)))
return build_fold_addr_expr_with_type (tem, type);
if ((TREE_CODE (op0) == MODIFY_EXPR
|| TREE_CODE (op0) == GIMPLE_MODIFY_STMT)
&& TREE_CONSTANT (GENERIC_TREE_OPERAND (op0, 1))

View file

@ -1,3 +1,7 @@
2007-04-08 Jan Hubicka <jh@suse.cz>
* gcc.dg/tree-ssa/foldaddr-2.c: New file.
2007-04-07 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31257

View file

@ -0,0 +1,13 @@
/* { dg-do compile } */
/* { dg-options "-O1 -fdump-tree-optimized" } */
struct a{
int a;
int b;
} a;
int *
t()
{
return (int *)&a;
}
/* { dg-final { scan-tree-dump "a.a" "optimized"} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */

View file

@ -1643,7 +1643,7 @@ maybe_fold_offset_to_array_ref (tree base, tree offset, tree orig_type)
is the desired result type. */
/* ??? This doesn't handle class inheritance. */
static tree
tree
maybe_fold_offset_to_component_ref (tree record_type, tree base, tree offset,
tree orig_type, bool base_is_ptr)
{

View file

@ -4412,6 +4412,8 @@ extern void fold_defer_overflow_warnings (void);
extern void fold_undefer_overflow_warnings (bool, tree, int);
extern void fold_undefer_and_ignore_overflow_warnings (void);
extern bool fold_deferring_overflow_warnings_p (void);
extern tree maybe_fold_offset_to_component_ref (tree, tree, tree,
tree, bool);
extern tree force_fit_type_double (tree, unsigned HOST_WIDE_INT, HOST_WIDE_INT,
int, bool);