* tree-flow.h: Remove some prototypes.
* tree-ssa-dce.c (mark_virtual_operand_for_renaming,
mark_virtual_phi_result_for_renaming): Move to tree-into-ssa.c.
* tree-into-ssa.c (mark_virtual_operand_for_renaming,
mark_virtual_phi_result_for_renaming): Relocate here.
* tree-into-ssa.h: Add prototypes.
* tree-ssa-phiopt.c: (tree_ssa_phiopt_worker) Use
single_pred_before_succ_order.
(blocks_in_phiopt_order): Rename and move to cfganal.c.
(nonfreeing_call_p) Move to gimple.c.
* cfganal.c (single_pred_before_succ_order): Move and renamed from
tree-ssa-phiopt.c.
* basic-block.h (single_pred_before_succ_order): Add prototype.
* gimple.c (nonfreeing_call_p): Relocate here.
* gimple.h: Add prototype.
* tree-ssa-ifcombine.c: Include tree-ssa-phiopt.h.
* tree-ssa-dom.h: New file. Relocate prototypes here.
* tree-ssa.h: Include tree-ssa-dom.h.
===================================================================
*************** bool tree_node_can_be_shared (tree);
tree fold_const_aggregate_ref (tree);
tree gimple_fold_stmt_to_constant (gimple, tree (*)(tree));
- /* In tree-ssa-dom.c */
- extern void dump_dominator_optimization_stats (FILE *);
- extern void debug_dominator_optimization_stats (void);
- int loop_depth_of_name (tree);
- tree degenerate_phi_result (gimple);
- bool simple_iv_increment_p (gimple);
-
/* In tree-ssa-copy.c */
extern void propagate_value (use_operand_p, tree);
extern void propagate_tree_value (tree *, tree);
*************** struct tree_niter_desc
enum tree_code cmp;
};
- /* In tree-ssa-phiopt.c */
- bool empty_block_p (basic_block);
- basic_block *blocks_in_phiopt_order (void);
- bool nonfreeing_call_p (gimple);
/* In tree-ssa-loop*.c */
*************** void tree_transform_and_unroll_loop (str
bool contains_abnormal_ssa_name_p (tree);
bool stmt_dominates_stmt_p (gimple, gimple);
- /* In tree-ssa-dce.c */
- void mark_virtual_operand_for_renaming (tree);
- void mark_virtual_phi_result_for_renaming (gimple);
-
/* In tree-ssa-threadedge.c */
extern void threadedge_initialize_values (void);
extern void threadedge_finalize_values (void);
===================================================================
*************** propagate_necessity (bool aggressive)
}
}
- /* Replace all uses of NAME by underlying variable and mark it
- for renaming. This assumes the defining statement of NAME is
- going to be removed. */
-
- void
- mark_virtual_operand_for_renaming (tree name)
- {
- tree name_var = SSA_NAME_VAR (name);
- bool used = false;
- imm_use_iterator iter;
- use_operand_p use_p;
- gimple stmt;
-
- gcc_assert (VAR_DECL_IS_VIRTUAL_OPERAND (name_var));
- FOR_EACH_IMM_USE_STMT (stmt, iter, name)
- {
- FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
- SET_USE (use_p, name_var);
- used = true;
- }
- if (used)
- mark_virtual_operands_for_renaming (cfun);
- }
-
- /* Replace all uses of the virtual PHI result by its underlying variable
- and mark it for renaming. This assumes the PHI node is going to be
- removed. */
-
- void
- mark_virtual_phi_result_for_renaming (gimple phi)
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fprintf (dump_file, "Marking result for renaming : ");
- print_gimple_stmt (dump_file, phi, 0, TDF_SLIM);
- fprintf (dump_file, "\n");
- }
-
- mark_virtual_operand_for_renaming (gimple_phi_result (phi));
- }
-
-
/* Remove dead PHI nodes from block BB. */
static bool
===================================================================
*************** mark_virtual_operands_for_renaming (stru
fn->gimple_df->rename_vops = 1;
}
+ /* Replace all uses of NAME by underlying variable and mark it
+ for renaming. This assumes the defining statement of NAME is
+ going to be removed. */
+
+ void
+ mark_virtual_operand_for_renaming (tree name)
+ {
+ tree name_var = SSA_NAME_VAR (name);
+ bool used = false;
+ imm_use_iterator iter;
+ use_operand_p use_p;
+ gimple stmt;
+
+ gcc_assert (VAR_DECL_IS_VIRTUAL_OPERAND (name_var));
+ FOR_EACH_IMM_USE_STMT (stmt, iter, name)
+ {
+ FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
+ SET_USE (use_p, name_var);
+ used = true;
+ }
+ if (used)
+ mark_virtual_operands_for_renaming (cfun);
+ }
+
+ /* Replace all uses of the virtual PHI result by its underlying variable
+ and mark it for renaming. This assumes the PHI node is going to be
+ removed. */
+
+ void
+ mark_virtual_phi_result_for_renaming (gimple phi)
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "Marking result for renaming : ");
+ print_gimple_stmt (dump_file, phi, 0, TDF_SLIM);
+ fprintf (dump_file, "\n");
+ }
+
+ mark_virtual_operand_for_renaming (gimple_phi_result (phi));
+ }
/* Return true if there is any work to be done by update_ssa
for function FN. */
===================================================================
*************** extern void set_current_def (tree, tree)
void delete_update_ssa (void);
tree create_new_def_for (tree, gimple, def_operand_p);
void mark_virtual_operands_for_renaming (struct function *);
+ void mark_virtual_operand_for_renaming (tree);
+ void mark_virtual_phi_result_for_renaming (gimple);
bool need_ssa_update_p (struct function *);
bool name_registered_for_update_p (tree);
void release_ssa_name_after_update_ssa (tree);
===================================================================
*************** tree_ssa_phiopt_worker (bool do_store_el
This ensures that we collapse inner ifs before visiting the
outer ones, and also that we do not try to visit a removed
block. */
! bb_order = blocks_in_phiopt_order ();
n = n_basic_blocks - NUM_FIXED_BLOCKS;
for (i = 0; i < n; i++)
This ensures that we collapse inner ifs before visiting the
outer ones, and also that we do not try to visit a removed
block. */
! bb_order = single_pred_before_succ_order ();
n = n_basic_blocks - NUM_FIXED_BLOCKS;
for (i = 0; i < n; i++)
*************** tree_ssa_phiopt_worker (bool do_store_el
return 0;
}
- /* Returns the list of basic blocks in the function in an order that guarantees
- that if a block X has just a single predecessor Y, then Y is after X in the
- ordering. */
-
- basic_block *
- blocks_in_phiopt_order (void)
- {
- basic_block x, y;
- basic_block *order = XNEWVEC (basic_block, n_basic_blocks);
- unsigned n = n_basic_blocks - NUM_FIXED_BLOCKS;
- unsigned np, i;
- sbitmap visited = sbitmap_alloc (last_basic_block);
-
- #define MARK_VISITED(BB) (bitmap_set_bit (visited, (BB)->index))
- #define VISITED_P(BB) (bitmap_bit_p (visited, (BB)->index))
-
- bitmap_clear (visited);
-
- MARK_VISITED (ENTRY_BLOCK_PTR);
- FOR_EACH_BB (x)
- {
- if (VISITED_P (x))
- continue;
-
- /* Walk the predecessors of x as long as they have precisely one
- predecessor and add them to the list, so that they get stored
- after x. */
- for (y = x, np = 1;
- single_pred_p (y) && !VISITED_P (single_pred (y));
- y = single_pred (y))
- np++;
- for (y = x, i = n - np;
- single_pred_p (y) && !VISITED_P (single_pred (y));
- y = single_pred (y), i++)
- {
- order[i] = y;
- MARK_VISITED (y);
- }
- order[i] = y;
- MARK_VISITED (y);
-
- gcc_assert (i == n - 1);
- n -= np;
- }
-
- sbitmap_free (visited);
- gcc_assert (n == 0);
- return order;
-
- #undef MARK_VISITED
- #undef VISITED_P
- }
-
/* Replace PHI node element whose edge is E in block BB with variable NEW.
Remove the edge from COND_BLOCK which does not lead to BB (COND_BLOCK
is known to have two edges, one of which must reach BB). */
*************** add_or_mark_expr (basic_block bb, tree e
}
}
- /* Return true when CALL is a call stmt that definitely doesn't
- free any memory or makes it unavailable otherwise. */
- bool
- nonfreeing_call_p (gimple call)
- {
- if (gimple_call_builtin_p (call, BUILT_IN_NORMAL)
- && gimple_call_flags (call) & ECF_LEAF)
- switch (DECL_FUNCTION_CODE (gimple_call_fndecl (call)))
- {
- /* Just in case these become ECF_LEAF in the future. */
- case BUILT_IN_FREE:
- case BUILT_IN_TM_FREE:
- case BUILT_IN_REALLOC:
- case BUILT_IN_STACK_RESTORE:
- return false;
- default:
- return true;
- }
-
- return false;
- }
-
class nontrapping_dom_walker : public dom_walker
{
public:
===================================================================
*************** bitmap_union_of_preds (sbitmap dst, sbit
*r++ |= *p++;
}
}
+
+ /* Returns the list of basic blocks in the function in an order that guarantees
+ that if a block X has just a single predecessor Y, then Y is after X in the
+ ordering. */
+
+ basic_block *
+ single_pred_before_succ_order (void)
+ {
+ basic_block x, y;
+ basic_block *order = XNEWVEC (basic_block, n_basic_blocks);
+ unsigned n = n_basic_blocks - NUM_FIXED_BLOCKS;
+ unsigned np, i;
+ sbitmap visited = sbitmap_alloc (last_basic_block);
+
+ #define MARK_VISITED(BB) (bitmap_set_bit (visited, (BB)->index))
+ #define VISITED_P(BB) (bitmap_bit_p (visited, (BB)->index))
+
+ bitmap_clear (visited);
+
+ MARK_VISITED (ENTRY_BLOCK_PTR);
+ FOR_EACH_BB (x)
+ {
+ if (VISITED_P (x))
+ continue;
+
+ /* Walk the predecessors of x as long as they have precisely one
+ predecessor and add them to the list, so that they get stored
+ after x. */
+ for (y = x, np = 1;
+ single_pred_p (y) && !VISITED_P (single_pred (y));
+ y = single_pred (y))
+ np++;
+ for (y = x, i = n - np;
+ single_pred_p (y) && !VISITED_P (single_pred (y));
+ y = single_pred (y), i++)
+ {
+ order[i] = y;
+ MARK_VISITED (y);
+ }
+ order[i] = y;
+ MARK_VISITED (y);
+
+ gcc_assert (i == n - 1);
+ n -= np;
+ }
+
+ sbitmap_free (visited);
+ gcc_assert (n == 0);
+ return order;
+
+ #undef MARK_VISITED
+ #undef VISITED_P
+ }
===================================================================
*************** extern int dfs_enumerate_from (basic_blo
basic_block *, int, const void *);
extern void compute_dominance_frontiers (struct bitmap_head_def *);
extern bitmap compute_idf (bitmap, struct bitmap_head_def *);
+ extern basic_block * single_pred_before_succ_order (void);
/* In cfgrtl.c */
extern rtx block_label (basic_block);
===================================================================
*************** gimple_can_coalesce_p (tree name1, tree
return false;
}
+
+ /* Return true when CALL is a call stmt that definitely doesn't
+ free any memory or makes it unavailable otherwise. */
+ bool
+ nonfreeing_call_p (gimple call)
+ {
+ if (gimple_call_builtin_p (call, BUILT_IN_NORMAL)
+ && gimple_call_flags (call) & ECF_LEAF)
+ switch (DECL_FUNCTION_CODE (gimple_call_fndecl (call)))
+ {
+ /* Just in case these become ECF_LEAF in the future. */
+ case BUILT_IN_FREE:
+ case BUILT_IN_TM_FREE:
+ case BUILT_IN_REALLOC:
+ case BUILT_IN_STACK_RESTORE:
+ return false;
+ default:
+ return true;
+ }
+
+ return false;
+ }
+
#include "gt-gimple.h"
===================================================================
*************** extern tree gimple_boolify (tree);
extern gimple_predicate rhs_predicate_for (tree);
extern tree canonicalize_cond_expr_cond (tree);
extern void dump_decl_set (FILE *, bitmap);
+ extern bool nonfreeing_call_p (gimple);
/* In omp-low.c. */
extern tree omp_reduction_init (tree, tree);
===================================================================
*************** tree_ssa_ifcombine (void)
bool cfg_changed = false;
int i;
! bbs = blocks_in_phiopt_order ();
calculate_dominance_info (CDI_DOMINATORS);
for (i = 0; i < n_basic_blocks - NUM_FIXED_BLOCKS; ++i)
bool cfg_changed = false;
int i;
! bbs = single_pred_before_succ_order ();
calculate_dominance_info (CDI_DOMINATORS);
for (i = 0; i < n_basic_blocks - NUM_FIXED_BLOCKS; ++i)
===================================================================
***************
+ /* Header file for SSA dominator optimizations.
+ Copyright (C) 2013 Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 3, or (at your option) any later
+ version.
+
+ GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
+ #ifndef GCC_TREE_SSA_DOM_H
+ #define GCC_TREE_SSA_DOM_H
+
+ extern void dump_dominator_optimization_stats (FILE *);
+ extern void debug_dominator_optimization_stats (void);
+ extern int loop_depth_of_name (tree);
+ extern bool simple_iv_increment_p (gimple);
+ extern tree degenerate_phi_result (gimple);
+
+ #endif /* GCC_TREE_SSA_DOM_H */
===================================================================
*************** along with GCC; see the file COPYING3.
#include "gimple-ssa.h"
#include "ssa-iterators.h"
#include "tree-ssanames.h"
+ #include "tree-ssa-dom.h"
#include "tree-flow.h"
/* Mapping for redirected edges. */