aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-forwprop.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2009-04-09 08:05:43 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2009-04-09 08:05:43 +0000
commitf76968e6d5ab3ca8bd5b64ba0143197c00f59943 (patch)
treea08a54da6efd905c9042e644d8017899d9d9c0f1 /gcc/tree-ssa-forwprop.c
parentc90c5fb5a5e09a6405c7dbfa145bf3a9baf70fad (diff)
downloadgcc-f76968e6d5ab3ca8bd5b64ba0143197c00f59943.zip
gcc-f76968e6d5ab3ca8bd5b64ba0143197c00f59943.tar.gz
gcc-f76968e6d5ab3ca8bd5b64ba0143197c00f59943.tar.bz2
tree-ssa-ccp.c (maybe_fold_stmt_addition): Move non-constant indices into an array reference if possible.
2009-04-09 Richard Guenther <rguenther@suse.de> * tree-ssa-ccp.c (maybe_fold_stmt_addition): Move non-constant indices into an array reference if possible. * tree-ssa-forwprop.c (tree_ssa_forward_propagate_single_use_vars): Fold POINTER_PLUS_EXPR statements with invariant address. * gcc.dg/tree-ssa/ssa-ccp-25.c: New testcase. * gcc.dg/tree-ssa/ssa-ccp-26.c: Likewise. From-SVN: r145799
Diffstat (limited to 'gcc/tree-ssa-forwprop.c')
-rw-r--r--gcc/tree-ssa-forwprop.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index ff6bda0..f75e0af 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -1256,6 +1256,15 @@ tree_ssa_forward_propagate_single_use_vars (void)
else
gsi_next (&gsi);
}
+ else if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR
+ && is_gimple_min_invariant (rhs))
+ {
+ /* Make sure to fold &a[0] + off_1 here. */
+ fold_stmt_inplace (stmt);
+ update_stmt (stmt);
+ if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR)
+ gsi_next (&gsi);
+ }
else if ((gimple_assign_rhs_code (stmt) == BIT_NOT_EXPR
|| gimple_assign_rhs_code (stmt) == NEGATE_EXPR)
&& TREE_CODE (rhs) == SSA_NAME)