diff options
author | Jan Hubicka <jh@suse.cz> | 2007-04-09 00:12:21 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2007-04-08 22:12:21 +0000 |
commit | c586d32a1e2cc9997c4c9a05f08a33436710559d (patch) | |
tree | d155309522eafe8f8aa9080b7fa88971868cdef3 /gcc/fold-const.c | |
parent | 136cdb2250cf60a040cd419c51e9850415ec511c (diff) | |
download | gcc-c586d32a1e2cc9997c4c9a05f08a33436710559d.zip gcc-c586d32a1e2cc9997c4c9a05f08a33436710559d.tar.gz gcc-c586d32a1e2cc9997c4c9a05f08a33436710559d.tar.bz2 |
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
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index a8b6f34..ceaa446 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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)) |