diff options
author | Zdenek Dvorak <dvorakz@suse.cz> | 2005-05-17 22:28:30 +0200 |
---|---|---|
committer | Zdenek Dvorak <rakdver@gcc.gnu.org> | 2005-05-17 20:28:30 +0000 |
commit | 684aaf29c03351ad615ef8dd3ff52e1e312704c2 (patch) | |
tree | 67bc73975832051c0cb714b9f0601f6188091223 /gcc/tree-scalar-evolution.c | |
parent | 7dc5e63544e434b07f0fcc0737a4caa371e5457b (diff) | |
download | gcc-684aaf29c03351ad615ef8dd3ff52e1e312704c2.zip gcc-684aaf29c03351ad615ef8dd3ff52e1e312704c2.tar.gz gcc-684aaf29c03351ad615ef8dd3ff52e1e312704c2.tar.bz2 |
timevar.def (TV_SCEV_CONST): New timevar.
* timevar.def (TV_SCEV_CONST): New timevar.
* tree-optimize.c (init_tree_optimization_passes): Add
pass_scev_cprop.
* tree-pass.h (pass_scev_cprop): Declare.
* tree-scalar-evolution.c (scev_const_prop): New function.
* tree-scalar-evolution.h (scev_const_prop): Declare.
* tree-ssa-loop.c (gate_scev_const_prop, pass_scev_cprop):
New.
* tree-cfg.c (replace_uses_by): Export.
* tree-flow.h (replace_uses_by): Declare.
From-SVN: r99860
Diffstat (limited to 'gcc/tree-scalar-evolution.c')
-rw-r--r-- | gcc/tree-scalar-evolution.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 4019f78..4ff50e6 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -2627,3 +2627,72 @@ scev_finalize (void) BITMAP_FREE (already_instantiated); } +/* Replace ssa names for that scev can prove they are constant by the + appropriate constants. Most importantly, this takes care of final + value replacement. + + We only consider SSA names defined by phi nodes; rest is left to the + ordinary constant propagation pass. */ + +void +scev_const_prop (void) +{ + basic_block bb; + tree name, phi, type, ev; + struct loop *loop; + bitmap ssa_names_to_remove = NULL; + + if (!current_loops) + return; + + FOR_EACH_BB (bb) + { + loop = bb->loop_father; + + for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi)) + { + name = PHI_RESULT (phi); + + if (!is_gimple_reg (name)) + continue; + + type = TREE_TYPE (name); + + if (!POINTER_TYPE_P (type) + && !INTEGRAL_TYPE_P (type)) + continue; + + ev = resolve_mixers (loop, analyze_scalar_evolution (loop, name)); + if (!is_gimple_min_invariant (ev) + || !may_propagate_copy (name, ev)) + continue; + + /* Replace the uses of the name. */ + replace_uses_by (name, ev); + + if (!ssa_names_to_remove) + ssa_names_to_remove = BITMAP_ALLOC (NULL); + bitmap_set_bit (ssa_names_to_remove, SSA_NAME_VERSION (name)); + } + } + + /* Remove the ssa names that were replaced by constants. We do not remove them + directly in the previous cycle, since this invalidates scev cache. */ + if (ssa_names_to_remove) + { + bitmap_iterator bi; + unsigned i; + + EXECUTE_IF_SET_IN_BITMAP (ssa_names_to_remove, 0, i, bi) + { + name = ssa_name (i); + phi = SSA_NAME_DEF_STMT (name); + + gcc_assert (TREE_CODE (phi) == PHI_NODE); + remove_phi_node (phi, NULL); + } + + BITMAP_FREE (ssa_names_to_remove); + scev_reset (); + } +} |