aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2009-03-31 10:23:44 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2009-03-31 10:23:44 +0000
commitba4d8f9d37bf11be3a98504812447cd9bbaad708 (patch)
tree5f692532b5bfb1559215c17e5d2b5753f7a01415 /gcc/gimple.c
parent8de9b877e7853c725c1a9cc4dc5e18c39debf41d (diff)
downloadgcc-ba4d8f9d37bf11be3a98504812447cd9bbaad708.zip
gcc-ba4d8f9d37bf11be3a98504812447cd9bbaad708.tar.gz
gcc-ba4d8f9d37bf11be3a98504812447cd9bbaad708.tar.bz2
re PR middle-end/23401 (Gimplifier produces too many temporaries)
2009-03-31 Richard Guenther <rguenther@suse.de> PR middle-end/23401 PR middle-end/27810 * tree.h (DECL_GIMPLE_FORMAL_TEMP_P): Remove. (struct tree_decl_with_vis): Remove gimple_formal_temp member. * tree-eh.c (lower_eh_constructs_2): Move LHS assignment to a separate statement. * gimplify.c (pop_gimplify_context): Remove formal temp handling. (lookup_tmp_var): Likewise. (is_gimple_formal_tmp_or_call_rhs): Remove. (is_gimple_reg_or_call_rhs): Rename to ... (is_gimple_reg_rhs_or_call): ... this. (is_gimple_mem_or_call_rhs): Rename to ... (is_gimple_mem_rhs_or_call): ... this. (internal_get_tmp_var): Use is_gimple_reg_rhs_or_call. Set DECL_GIMPLE_REG_P only if is_formal is true. (gimplify_compound_lval): Use is_gimple_reg. Remove workaround for non-proper post-modify expression gimplification. (gimplify_self_mod_expr): For post-modify expressions gimplify the lvalue to a minimal lvalue. (rhs_predicate_for): Remove formal temp case. (gimplify_modify_expr_rhs): Likewise. (gimplify_addr_expr): Use is_gimple_reg. (gimplify_expr): Remove formal temp cases. (gimple_regimplify_operands): Likewise. * tree-ssa-pre.c (get_or_alloc_expr_for): Treat EXC_PTR_EXPR and FILTER_EXPR like constants. * gimple.c (walk_gimple_op): Fix val_only initialization, use is_gimple_reg. (is_gimple_formal_tmp_rhs): Remove. (is_gimple_reg_rhs): Remove special casing. (is_gimple_mem_rhs): Fix. (is_gimple_reg): Move DECL_GIMPLE_REG_P handling earlier. (is_gimple_formal_tmp_var): Remove. (is_gimple_formal_tmp_reg): Likewise. (is_gimple_min_lval): Allow invariant component ref parts. * gimple.h (is_gimple_formal_tmp_rhs, is_gimple_formal_tmp_var, is_gimple_formal_tmp_reg): Remove declarations. * tree-cfg.c (verify_expr): Verify that variables with address taken do not have DECL_GIMPLE_REG_P set. * tree-mudflap.c (mf_build_check_statement_for): Use force_gimple_operand instead of gimplify_expr. java/ * java-gimplify.c (java_gimplify_expr): Do not manually gimplify the first operand of binary and comaprison expressions. * gcc.dg/tree-ssa/pr23401.c: New testcase. * gcc.dg/tree-ssa/pr27810.c: Likewise. From-SVN: r145338
Diffstat (limited to 'gcc/gimple.c')
-rw-r--r--gcc/gimple.c74
1 files changed, 12 insertions, 62 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 90de9b3..a1dd6a7 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1380,7 +1380,8 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
/* Walk the RHS operands. A formal temporary LHS may use a
COMPONENT_REF RHS. */
if (wi)
- wi->val_only = !is_gimple_formal_tmp_var (gimple_assign_lhs (stmt));
+ wi->val_only = !is_gimple_reg (gimple_assign_lhs (stmt))
+ || !gimple_assign_single_p (stmt);
for (i = 1; i < gimple_num_ops (stmt); i++)
{
@@ -2559,37 +2560,13 @@ is_gimple_operand (const_tree op)
return op && get_gimple_rhs_class (TREE_CODE (op)) == GIMPLE_SINGLE_RHS;
}
-
-/* Return true if T is a GIMPLE RHS for an assignment to a temporary. */
-
-bool
-is_gimple_formal_tmp_rhs (tree t)
-{
- if (is_gimple_lvalue (t) || is_gimple_val (t))
- return true;
-
- return get_gimple_rhs_class (TREE_CODE (t)) != GIMPLE_INVALID_RHS;
-}
-
/* Returns true iff T is a valid RHS for an assignment to a renamed
user -- or front-end generated artificial -- variable. */
bool
is_gimple_reg_rhs (tree t)
{
- /* If the RHS of the MODIFY_EXPR may throw or make a nonlocal goto
- and the LHS is a user variable, then we need to introduce a formal
- temporary. This way the optimizers can determine that the user
- variable is only modified if evaluation of the RHS does not throw.
-
- Don't force a temp of a non-renamable type; the copy could be
- arbitrarily expensive. Instead we will generate a VDEF for
- the assignment. */
-
- if (is_gimple_reg_type (TREE_TYPE (t)) && tree_could_throw_p (t))
- return false;
-
- return is_gimple_formal_tmp_rhs (t);
+ return get_gimple_rhs_class (TREE_CODE (t)) != GIMPLE_INVALID_RHS;
}
/* Returns true iff T is a valid RHS for an assignment to an un-renamed
@@ -2603,7 +2580,7 @@ is_gimple_mem_rhs (tree t)
if (is_gimple_reg_type (TREE_TYPE (t)))
return is_gimple_val (t);
else
- return is_gimple_formal_tmp_rhs (t);
+ return is_gimple_val (t) || is_gimple_lvalue (t);
}
/* Return true if T is a valid LHS for a GIMPLE assignment expression. */
@@ -2895,6 +2872,12 @@ is_gimple_reg (tree t)
if (!is_gimple_variable (t))
return false;
+ /* Complex and vector values must have been put into SSA-like form.
+ That is, no assignments to the individual components. */
+ if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE
+ || TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE)
+ return DECL_GIMPLE_REG_P (t);
+
if (!is_gimple_reg_type (TREE_TYPE (t)))
return false;
@@ -2921,45 +2904,10 @@ is_gimple_reg (tree t)
if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
return false;
- /* Complex and vector values must have been put into SSA-like form.
- That is, no assignments to the individual components. */
- if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE
- || TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE)
- return DECL_GIMPLE_REG_P (t);
-
return true;
}
-/* Returns true if T is a GIMPLE formal temporary variable. */
-
-bool
-is_gimple_formal_tmp_var (tree t)
-{
- if (TREE_CODE (t) == SSA_NAME)
- return true;
-
- return TREE_CODE (t) == VAR_DECL && DECL_GIMPLE_FORMAL_TEMP_P (t);
-}
-
-/* Returns true if T is a GIMPLE formal temporary register variable. */
-
-bool
-is_gimple_formal_tmp_reg (tree t)
-{
- /* The intent of this is to get hold of a value that won't change.
- An SSA_NAME qualifies no matter if its of a user variable or not. */
- if (TREE_CODE (t) == SSA_NAME)
- return true;
-
- /* We don't know the lifetime characteristics of user variables. */
- if (!is_gimple_formal_tmp_var (t))
- return false;
-
- /* Finally, it must be capable of being placed in a register. */
- return is_gimple_reg (t);
-}
-
/* Return true if T is a GIMPLE variable whose address is not needed. */
bool
@@ -3006,6 +2954,8 @@ is_gimple_asm_val (tree t)
bool
is_gimple_min_lval (tree t)
{
+ if (!(t = CONST_CAST_TREE (strip_invariant_refs (t))))
+ return false;
return (is_gimple_id (t) || TREE_CODE (t) == INDIRECT_REF);
}