diff options
author | Richard Guenther <rguenther@suse.de> | 2008-03-20 22:06:40 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-03-20 22:06:40 +0000 |
commit | 16ac8575504420eb56680d82edbd6c8879a67faf (patch) | |
tree | bd5e138f1c805a2f582aec0ad63aaaa70c10283c /gcc/tree-ssa-ccp.c | |
parent | 44b6c5465840c7cd4737c0a0bc434c38dfa4eca4 (diff) | |
download | gcc-16ac8575504420eb56680d82edbd6c8879a67faf.zip gcc-16ac8575504420eb56680d82edbd6c8879a67faf.tar.gz gcc-16ac8575504420eb56680d82edbd6c8879a67faf.tar.bz2 |
tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Remove special casing of constant qualifiers.
2008-03-20 Richard Guenther <rguenther@suse.de>
* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Remove
special casing of constant qualifiers.
* tree-ssa.c (useless_type_conversion_p_1): Instead do not
care about them in general.
* tree-ssa-ccp.c (ccp_fold): Addresses are constant or not
regardless of their type.
(fold_stmt_r): Forcefully fold *& if we end up with that.
* gcc.dg/tree-ssa/ssa-ccp-17.c: New testcase.
From-SVN: r133400
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 2a82c04..7797de1 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -947,8 +947,15 @@ ccp_fold (tree stmt) op0 = get_value (op0)->value; } + /* Conversions are useless for CCP purposes if they are + value-preserving. Thus the restrictions that + useless_type_conversion_p places for pointer type conversions do + not apply here. Substitution later will only substitute to + allowed places. */ if ((code == NOP_EXPR || code == CONVERT_EXPR) - && useless_type_conversion_p (TREE_TYPE (rhs), TREE_TYPE (op0))) + && ((POINTER_TYPE_P (TREE_TYPE (rhs)) + && POINTER_TYPE_P (TREE_TYPE (op0))) + || useless_type_conversion_p (TREE_TYPE (rhs), TREE_TYPE (op0)))) return op0; return fold_unary (code, TREE_TYPE (rhs), op0); } @@ -2160,6 +2167,11 @@ fold_stmt_r (tree *expr_p, int *walk_subtrees, void *data) t = maybe_fold_stmt_indirect (expr, TREE_OPERAND (expr, 0), integer_zero_node); + if (!t + && TREE_CODE (TREE_OPERAND (expr, 0)) == ADDR_EXPR) + /* If we had a good reason for propagating the address here, + make sure we end up with valid gimple. See PR34989. */ + t = TREE_OPERAND (TREE_OPERAND (expr, 0), 0); break; case NOP_EXPR: |