Merge evrp uses of substitute_and_fold_engine into the engine itself.
authorAldy Hernandez <aldyh@redhat.com>
Tue, 5 May 2020 11:45:39 +0000 (13:45 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Wed, 10 Jun 2020 13:09:37 +0000 (15:09 +0200)
commit1396fa5b91cfa0b3708ec9df33c0bb84386081d6
treed5eb6c1149ef54835dcc6b0d2d7be8fa28de1d03
parent8b6731e674c76cb48a417f2eef74ced92a17f469
Merge evrp uses of substitute_and_fold_engine into the engine itself.

This patch merges the evrp uses of the substitute and fold engine into
the engine itself, at least the parts that can be re-used by other
engine uses.  It also adds a context parameter to get_value() for
further use.

gcc/
* gimple-loop-versioning.cc (loop_versioning::name_prop::get_value):
Add stmt parameter.
* gimple-ssa-evrp.c (class evrp_folder): New.
(class evrp_dom_walker): Remove.
(execute_early_vrp): Use evrp_folder instead of evrp_dom_walker.
* tree-ssa-ccp.c (ccp_folder::get_value): Add stmt parameter.
* tree-ssa-copy.c (copy_folder::get_value): Same.
* tree-ssa-propagate.c (substitute_and_fold_engine::replace_uses_in):
Pass stmt to get_value.
(substitute_and_fold_engine::replace_phi_args_in): Same.
(substitute_and_fold_dom_walker::after_dom_children): Call
post_fold_bb.
(substitute_and_fold_dom_walker::foreach_new_stmt_in_bb): New.
(substitute_and_fold_dom_walker::propagate_into_phi_args): New.
(substitute_and_fold_dom_walker::before_dom_children): Adjust to
call virtual functions for folding, pre_folding, and post folding.
Call get_value with PHI.  Tweak dump.
* tree-ssa-propagate.h (class substitute_and_fold_engine):
New argument to get_value.
New virtual function pre_fold_bb.
New virtual function post_fold_bb.
New virtual function pre_fold_stmt.
New virtual function post_new_stmt.
New function propagate_into_phi_args.
* tree-vrp.c (vrp_folder::get_value): Add stmt argument.
* vr-values.c (vr_values::extract_range_from_stmt): Adjust dump
output.
(vr_values::fold_cond): New.
(vr_values::simplify_cond_using_ranges_1): Call fold_cond.
* vr-values.h (class vr_values): Add
simplify_cond_using_ranges_when_edge_is_known.
gcc/testsuite/
* gcc.dg/tree-ssa/ssa-dse-30.c: Adjust test for folding of
memmove happening later.
gcc/gimple-loop-versioning.cc
gcc/gimple-ssa-evrp.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-30.c
gcc/tree-ssa-ccp.c
gcc/tree-ssa-copy.c
gcc/tree-ssa-propagate.c
gcc/tree-ssa-propagate.h
gcc/tree-vrp.c
gcc/vr-values.c
gcc/vr-values.h