diff options
author | Jakub Jelinek <jakub@redhat.com> | 2008-12-09 17:55:35 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2008-12-09 17:55:35 +0100 |
commit | bab4e8fbed8e7d10eb9c99635d513b3ee4197db0 (patch) | |
tree | e1fc6db592f653e87c5ae59795210387846d1c3f /gcc/tree-ssa-ccp.c | |
parent | b3b30b2401e192a42d4a75728dd198223573dd81 (diff) | |
download | gcc-bab4e8fbed8e7d10eb9c99635d513b3ee4197db0.zip gcc-bab4e8fbed8e7d10eb9c99635d513b3ee4197db0.tar.gz gcc-bab4e8fbed8e7d10eb9c99635d513b3ee4197db0.tar.bz2 |
re PR tree-optimization/35468 (LHS of assignment can be folded to a constant causing ICE)
PR tree-optimization/35468
* tree-ssa-ccp.c (fold_stmt_r): Don't fold reads from constant
string on LHS.
* gcc.dg/pr35468.c: New test.
* gcc.c-torture/compile/pr35468.c: New test.
From-SVN: r142598
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 82933f8..0908d54 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -2191,6 +2191,9 @@ fold_stmt_r (tree *expr_p, int *walk_subtrees, void *data) t = maybe_fold_stmt_indirect (expr, TREE_OPERAND (expr, 0), integer_zero_node); + /* Avoid folding *"abc" = 5 into 'a' = 5. */ + if (wi->is_lhs && t && TREE_CODE (t) == INTEGER_CST) + t = NULL_TREE; if (!t && TREE_CODE (TREE_OPERAND (expr, 0)) == ADDR_EXPR) /* If we had a good reason for propagating the address here, @@ -2219,8 +2222,10 @@ fold_stmt_r (tree *expr_p, int *walk_subtrees, void *data) Otherwise we'd be wasting time. */ case ARRAY_REF: /* If we are not processing expressions found within an - ADDR_EXPR, then we can fold constant array references. */ - if (!*inside_addr_expr_p) + ADDR_EXPR, then we can fold constant array references. + Don't fold on LHS either, to avoid folding "abc"[0] = 5 + into 'a' = 5. */ + if (!*inside_addr_expr_p && !wi->is_lhs) t = fold_read_from_constant_string (expr); else t = NULL; |