diff options
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r-- | gcc/tree-cfg.c | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index a9a9fdc..a80285b 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -1896,127 +1896,6 @@ struct tree_opt_pass pass_remove_useless_stmts = 0 /* letter */ }; - -/* Remove obviously useless statements in basic block BB. */ - -static void -cfg_remove_useless_stmts_bb (basic_block bb) -{ - block_stmt_iterator bsi; - tree stmt = NULL_TREE; - tree cond, var = NULL_TREE, val = NULL_TREE; - struct var_ann_d *ann; - - /* Check whether we come here from a condition, and if so, get the - condition. */ - if (!single_pred_p (bb) - || !(single_pred_edge (bb)->flags - & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE))) - return; - - cond = COND_EXPR_COND (last_stmt (single_pred (bb))); - - if (TREE_CODE (cond) == VAR_DECL || TREE_CODE (cond) == PARM_DECL) - { - var = cond; - val = (single_pred_edge (bb)->flags & EDGE_FALSE_VALUE - ? boolean_false_node : boolean_true_node); - } - else if (TREE_CODE (cond) == TRUTH_NOT_EXPR - && (TREE_CODE (TREE_OPERAND (cond, 0)) == VAR_DECL - || TREE_CODE (TREE_OPERAND (cond, 0)) == PARM_DECL)) - { - var = TREE_OPERAND (cond, 0); - val = (single_pred_edge (bb)->flags & EDGE_FALSE_VALUE - ? boolean_true_node : boolean_false_node); - } - else - { - if (single_pred_edge (bb)->flags & EDGE_FALSE_VALUE) - cond = invert_truthvalue (cond); - if (TREE_CODE (cond) == EQ_EXPR - && (TREE_CODE (TREE_OPERAND (cond, 0)) == VAR_DECL - || TREE_CODE (TREE_OPERAND (cond, 0)) == PARM_DECL) - && (TREE_CODE (TREE_OPERAND (cond, 1)) == VAR_DECL - || TREE_CODE (TREE_OPERAND (cond, 1)) == PARM_DECL - || TREE_CONSTANT (TREE_OPERAND (cond, 1)))) - { - var = TREE_OPERAND (cond, 0); - val = TREE_OPERAND (cond, 1); - } - else - return; - } - - /* Only work for normal local variables. */ - ann = var_ann (var); - if (!ann - || ann->may_aliases - || TREE_ADDRESSABLE (var)) - return; - - if (! TREE_CONSTANT (val)) - { - ann = var_ann (val); - if (!ann - || ann->may_aliases - || TREE_ADDRESSABLE (val)) - return; - } - - /* Ignore floating point variables, since comparison behaves weird for - them. */ - if (FLOAT_TYPE_P (TREE_TYPE (var))) - return; - - for (bsi = bsi_start (bb); !bsi_end_p (bsi);) - { - stmt = bsi_stmt (bsi); - - /* If the THEN/ELSE clause merely assigns a value to a variable/parameter - which is already known to contain that value, then remove the useless - THEN/ELSE clause. */ - if (TREE_CODE (stmt) == MODIFY_EXPR - && TREE_OPERAND (stmt, 0) == var - && operand_equal_p (val, TREE_OPERAND (stmt, 1), 0)) - { - bsi_remove (&bsi); - continue; - } - - /* Invalidate the var if we encounter something that could modify it. - Likewise for the value it was previously set to. Note that we only - consider values that are either a VAR_DECL or PARM_DECL so we - can test for conflict very simply. */ - if (TREE_CODE (stmt) == ASM_EXPR - || (TREE_CODE (stmt) == MODIFY_EXPR - && (TREE_OPERAND (stmt, 0) == var - || TREE_OPERAND (stmt, 0) == val))) - return; - - bsi_next (&bsi); - } -} - - -/* A CFG-aware version of remove_useless_stmts. */ - -void -cfg_remove_useless_stmts (void) -{ - basic_block bb; - -#ifdef ENABLE_CHECKING - verify_flow_info (); -#endif - - FOR_EACH_BB (bb) - { - cfg_remove_useless_stmts_bb (bb); - } -} - - /* Remove PHI nodes associated with basic block BB and all edges out of BB. */ static void |