summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-12-30 21:20:08 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-12-30 21:20:08 +0000
commit66e8b99c2aa6f09af3151d972da33d15e09a8d75 (patch)
treec2715b7747017c8deeb4499cf75d222f6d9a931a /gcc/tree-ssa-ccp.c
parentc13edb6795a08b73e7d82b5d81fd443deb2b72b4 (diff)
downloadgcc-66e8b99c2aa6f09af3151d972da33d15e09a8d75.tar.gz
re PR tree-optimization/38645 (ICE with volatile)
2008-12-30 Richard Guenther <rguenther@suse.de> PR tree-optimization/38645 * tree-ssa-ccp.c (fold_gimple_assign): Use the correct pointer type. * tree-ssa-dom.c (cprop_operand): Simplify. Do not propagate volatileness changing operands. * gcc.dg/pr38645.c: New testcase. From-SVN: r142967
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 0908d546f00..d68337fc402 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -2720,10 +2720,19 @@ fold_gimple_assign (gimple_stmt_iterator *si)
case GIMPLE_BINARY_RHS:
/* Try to fold pointer addition. */
if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR)
- result = maybe_fold_stmt_addition (
- TREE_TYPE (gimple_assign_lhs (stmt)),
- gimple_assign_rhs1 (stmt),
- gimple_assign_rhs2 (stmt));
+ {
+ tree type = TREE_TYPE (gimple_assign_rhs1 (stmt));
+ if (TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE)
+ {
+ type = build_pointer_type (TREE_TYPE (TREE_TYPE (type)));
+ if (!useless_type_conversion_p
+ (TREE_TYPE (gimple_assign_lhs (stmt)), type))
+ type = TREE_TYPE (gimple_assign_rhs1 (stmt));
+ }
+ result = maybe_fold_stmt_addition (type,
+ gimple_assign_rhs1 (stmt),
+ gimple_assign_rhs2 (stmt));
+ }
if (!result)
result = fold_binary (subcode,