diff options
author | Richard Guenther <rguenther@suse.de> | 2008-08-13 14:22:19 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-08-13 14:22:19 +0000 |
commit | 99f536cc68422955e36cc1a5f590d790f92f8001 (patch) | |
tree | a132b33918fa2aabf5676cd2cede6a9b1320407a /gcc/gimplify.c | |
parent | e3f05c4e92cbf9464253d7886899204fe7b9e0b8 (diff) | |
download | gcc-99f536cc68422955e36cc1a5f590d790f92f8001.zip gcc-99f536cc68422955e36cc1a5f590d790f92f8001.tar.gz gcc-99f536cc68422955e36cc1a5f590d790f92f8001.tar.bz2 |
tree.h (maybe_fold_offset_to_address): Declare.
2008-08-13 Richard Guenther <rguenther@suse.de>
* tree.h (maybe_fold_offset_to_address): Declare.
* tree-ssa-ccp.c (surely_varying_stmt_p): Fix typo in last commit.
(ccp_fold): Handle pointer conversions the same as fold_stmt.
Likewise for POINTER_PLUS_EXPR.
(maybe_fold_offset_to_reference): Enable disabled code.
(maybe_fold_offset_to_address): New function.
(fold_stmt_r): Use it.
(fold_gimple_assign): Likewise.
* gimplify.c (gimplify_conversion): Use maybe_fold_offset_to_address.
(gimplify_expr): Likewise.
* gcc.dg/tree-ssa/ssa-ccp-21.c: New testcase.
* gcc.dg/tree-ssa/ssa-ccp-22.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-23.c: Likewise.
From-SVN: r139061
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 753aa59..43c8df9 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1842,17 +1842,13 @@ gimplify_conversion (tree *expr_p) /* Attempt to avoid NOP_EXPR by producing reference to a subtype. For example this fold (subclass *)&A into &A->subclass avoiding a need for statement. */ - if (TREE_CODE (*expr_p) == NOP_EXPR + if (CONVERT_EXPR_P (*expr_p) && POINTER_TYPE_P (TREE_TYPE (*expr_p)) && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (*expr_p, 0))) - && (tem = maybe_fold_offset_to_reference + && (tem = maybe_fold_offset_to_address (TREE_OPERAND (*expr_p, 0), - integer_zero_node, TREE_TYPE (TREE_TYPE (*expr_p))))) - { - tree ptr_type = build_pointer_type (TREE_TYPE (tem)); - if (useless_type_conversion_p (TREE_TYPE (*expr_p), ptr_type)) - *expr_p = build_fold_addr_expr_with_type (tem, ptr_type); - } + integer_zero_node, TREE_TYPE (*expr_p))) != NULL_TREE) + *expr_p = tem; /* If we still have a conversion at the toplevel, then canonicalize some constructs. */ @@ -6735,30 +6731,24 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, The second is gimple immediate saving a need for extra statement. */ if (TREE_CODE (TREE_OPERAND (*expr_p, 1)) == INTEGER_CST - && (tmp = maybe_fold_offset_to_reference + && (tmp = maybe_fold_offset_to_address (TREE_OPERAND (*expr_p, 0), TREE_OPERAND (*expr_p, 1), - TREE_TYPE (TREE_TYPE (*expr_p))))) - { - tree ptr_type = build_pointer_type (TREE_TYPE (tmp)); - if (useless_type_conversion_p (TREE_TYPE (*expr_p), ptr_type)) - { - *expr_p = build_fold_addr_expr_with_type (tmp, ptr_type); - break; - } - } + TREE_TYPE (*expr_p)))) + { + *expr_p = tmp; + break; + } /* Convert (void *)&a + 4 into (void *)&a[1]. */ if (TREE_CODE (TREE_OPERAND (*expr_p, 0)) == NOP_EXPR && TREE_CODE (TREE_OPERAND (*expr_p, 1)) == INTEGER_CST && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*expr_p, 0),0))) - && (tmp = maybe_fold_offset_to_reference + && (tmp = maybe_fold_offset_to_address (TREE_OPERAND (TREE_OPERAND (*expr_p, 0), 0), TREE_OPERAND (*expr_p, 1), - TREE_TYPE (TREE_TYPE - (TREE_OPERAND (TREE_OPERAND (*expr_p, 0), - 0)))))) + TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*expr_p, 0), + 0))))) { - tmp = build_fold_addr_expr (tmp); *expr_p = fold_convert (TREE_TYPE (*expr_p), tmp); break; } |