From 9e11641d112ecb3a6067c7223a8e249a1d63b9a1 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Wed, 2 Jul 2008 11:25:26 +0000 Subject: [PATCH] tree-ssa-forwprop.c (can_propagate_from): Exclude loads from decls explicitly. 2008-07-02 Richard Guenther * tree-ssa-forwprop.c (can_propagate_from): Exclude loads from decls explicitly. Merge operand checking from tuples. From-SVN: r137352 --- gcc/ChangeLog | 5 +++++ gcc/tree-ssa-forwprop.c | 31 ++++++++----------------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bb3362e6d9b..9a0c28390ae 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-07-02 Richard Guenther + + * tree-ssa-forwprop.c (can_propagate_from): Exclude loads + from decls explicitly. Merge operand checking from tuples. + 2008-07-02 Martin Jambor * tree-switch-conversion.c: Included timevar.h which I forgot before. diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index ac9d8514784..c49f0a48909 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -257,42 +257,27 @@ static bool can_propagate_from (tree def_stmt) { tree rhs = GIMPLE_STMT_OPERAND (def_stmt, 1); + use_operand_p use_p; + ssa_op_iter iter; /* If the rhs has side-effects we cannot propagate from it. */ if (TREE_SIDE_EFFECTS (rhs)) return false; /* If the rhs is a load we cannot propagate from it. */ - if (REFERENCE_CLASS_P (rhs)) + if (REFERENCE_CLASS_P (rhs) + || DECL_P (rhs)) return false; /* Constants can be always propagated. */ if (is_gimple_min_invariant (rhs)) return true; - /* We cannot propagate ssa names that occur in abnormal phi nodes. */ - switch (TREE_CODE_LENGTH (TREE_CODE (rhs))) - { - case 3: - if (TREE_OPERAND (rhs, 2) != NULL_TREE - && TREE_CODE (TREE_OPERAND (rhs, 2)) == SSA_NAME - && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (TREE_OPERAND (rhs, 2))) - return false; - case 2: - if (TREE_OPERAND (rhs, 1) != NULL_TREE - && TREE_CODE (TREE_OPERAND (rhs, 1)) == SSA_NAME - && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (TREE_OPERAND (rhs, 1))) - return false; - case 1: - if (TREE_OPERAND (rhs, 0) != NULL_TREE - && TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME - && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (TREE_OPERAND (rhs, 0))) - return false; - break; - - default: + /* If any of the SSA operands occurs in abnormal PHIs we cannot + propagate from this stmt. */ + FOR_EACH_SSA_USE_OPERAND (use_p, def_stmt, iter, SSA_OP_USE) + if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (USE_FROM_PTR (use_p))) return false; - } /* If the definition is a conversion of a pointer to a function type, then we can not apply optimizations as some targets require function -- 2.30.2