From f76968e6d5ab3ca8bd5b64ba0143197c00f59943 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Thu, 9 Apr 2009 08:05:43 +0000 Subject: tree-ssa-ccp.c (maybe_fold_stmt_addition): Move non-constant indices into an array reference if possible. 2009-04-09 Richard Guenther * 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 --- gcc/tree-ssa-forwprop.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/tree-ssa-forwprop.c') 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) -- cgit v1.1