diff options
author | Richard Biener <rguenther@suse.de> | 2018-11-05 11:11:04 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2018-11-05 11:11:04 +0000 |
commit | 4cc31a3c4ee108d960eb003129f05d5950f08355 (patch) | |
tree | a705d138f11930f3ce3c457f5d7b8970061fcd68 /gcc/tree-scalar-evolution.c | |
parent | 18e0c3d1718157761e3f23ddc33ae22393bef15f (diff) | |
download | gcc-4cc31a3c4ee108d960eb003129f05d5950f08355.zip gcc-4cc31a3c4ee108d960eb003129f05d5950f08355.tar.gz gcc-4cc31a3c4ee108d960eb003129f05d5950f08355.tar.bz2 |
tree-scalar-evolution.h (final_value_replacement_loop): Update prototype.
2018-11-05 Richard Biener <rguenther@suse.de>
* tree-scalar-evolution.h (final_value_replacement_loop): Update
prototype.
* tree-scalar-evolution.c (final_value_replacement_loop): Return
whether anything was done.
(scev_const_prop): Remove constant propagation part, fold
remains into ...
* tree-ssa-loop.c (pass_scev_cprop::execute): ... here.
(pass_data_scev_cprop): TODO_cleanup_cfg is now done
conditionally.
* gcc.dg/pr41488.c: Scan ivcanon dump instead of sccp one.
* gcc.dg/tree-ssa/scev-7.c: Likewise.
From-SVN: r265795
Diffstat (limited to 'gcc/tree-scalar-evolution.c')
-rw-r--r-- | gcc/tree-scalar-evolution.c | 104 |
1 files changed, 7 insertions, 97 deletions
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 6475743..02174b1 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -3537,20 +3537,20 @@ expression_expensive_p (tree expr) } } -/* Do final value replacement for LOOP. */ +/* Do final value replacement for LOOP, return true if we did anything. */ -void +bool final_value_replacement_loop (struct loop *loop) { /* If we do not know exact number of iterations of the loop, we cannot replace the final value. */ edge exit = single_exit (loop); if (!exit) - return; + return false; tree niter = number_of_latch_executions (loop); if (niter == chrec_dont_know) - return; + return false; /* Ensure that it is possible to insert new statements somewhere. */ if (!single_pred_p (exit->dest)) @@ -3563,6 +3563,7 @@ final_value_replacement_loop (struct loop *loop) = superloop_at_depth (loop, loop_depth (exit->dest->loop_father) + 1); + bool any = false; gphi_iterator psi; for (psi = gsi_start_phis (exit->dest); !gsi_end_p (psi); ) { @@ -3620,6 +3621,7 @@ final_value_replacement_loop (struct loop *loop) fprintf (dump_file, " with expr: "); print_generic_expr (dump_file, def); } + any = true; def = unshare_expr (def); remove_phi_node (&psi, false); @@ -3662,100 +3664,8 @@ final_value_replacement_loop (struct loop *loop) fprintf (dump_file, "\n"); } } -} - -/* Replace ssa names for that scev can prove they are constant by the - appropriate constants. Also perform final value replacement in loops, - in case the replacement expressions are cheap. - - We only consider SSA names defined by phi nodes; rest is left to the - ordinary constant propagation pass. */ - -unsigned int -scev_const_prop (void) -{ - basic_block bb; - tree name, type, ev; - gphi *phi; - struct loop *loop; - bitmap ssa_names_to_remove = NULL; - unsigned i; - gphi_iterator psi; - - if (number_of_loops (cfun) <= 1) - return 0; - - FOR_EACH_BB_FN (bb, cfun) - { - loop = bb->loop_father; - - for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi)) - { - phi = psi.phi (); - name = PHI_RESULT (phi); - - if (virtual_operand_p (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), - NULL); - if (!is_gimple_min_invariant (ev) - || !may_propagate_copy (name, ev)) - continue; - - /* Replace the uses of the name. */ - if (name != ev) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Replacing uses of: "); - print_generic_expr (dump_file, name); - fprintf (dump_file, " with: "); - print_generic_expr (dump_file, ev); - fprintf (dump_file, "\n"); - } - 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; - - EXECUTE_IF_SET_IN_BITMAP (ssa_names_to_remove, 0, i, bi) - { - gimple_stmt_iterator psi; - name = ssa_name (i); - phi = as_a <gphi *> (SSA_NAME_DEF_STMT (name)); - - gcc_assert (gimple_code (phi) == GIMPLE_PHI); - psi = gsi_for_stmt (phi); - remove_phi_node (&psi, true); - } - - BITMAP_FREE (ssa_names_to_remove); - scev_reset (); - } - - /* Now the regular final value replacement. */ - FOR_EACH_LOOP (loop, LI_FROM_INNERMOST) - final_value_replacement_loop (loop); - return 0; + return any; } #include "gt-tree-scalar-evolution.h" |