diff options
author | Jeff Law <law@redhat.com> | 2017-11-01 16:52:34 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2017-11-01 16:52:34 -0600 |
commit | e10a635c274f90cc2241394b1d17e291adcbf153 (patch) | |
tree | 9ebad3083f2dd86e7aad41a9fa1673917493aea8 /gcc/tree-vrp.c | |
parent | d9a3704a0bc83286afc179bc5e638ad6f7460bb3 (diff) | |
download | gcc-e10a635c274f90cc2241394b1d17e291adcbf153.zip gcc-e10a635c274f90cc2241394b1d17e291adcbf153.tar.gz gcc-e10a635c274f90cc2241394b1d17e291adcbf153.tar.bz2 |
tree-ssa-ccp.c (ccp_folder): New class derived from substitute_and_fold_engine.
* tree-ssa-ccp.c (ccp_folder): New class derived from
substitute_and_fold_engine.
(ccp_folder::get_value): New member function.
(ccp_folder::fold_stmt): Renamed from ccp_fold_stmt.
(ccp_fold_stmt): Remove prototype.
(ccp_finalize): Call substitute_and_fold from the ccp_class.
* tree-ssa-copy.c (copy_folder): New class derived from
substitute_and_fold_engine.
(copy_folder::get_value): Renamed from get_value.
(fini_copy_prop): Call substitute_and_fold from copy_folder class.
* tree-vrp.c (vrp_folder): New class derived from
substitute_and_fold_engine.
(vrp_folder::fold_stmt): Renamed from vrp_fold_stmt.
(vrp_folder::get_value): New member function.
(vrp_finalize): Call substitute_and_fold from vrp_folder class.
(evrp_dom_walker::before_dom_children): Similarly for replace_uses_in.
* tree-ssa-propagate.h (substitute_and_fold_engine): New class to
provide a class interface to folder/substitute routines.
(ssa_prop_fold_stmt_fn): Remove typedef.
(ssa_prop_get_value_fn): Likewise.
(subsitute_and_fold): Remove prototype.
(replace_uses_in): Likewise.
* tree-ssa-propagate.c (substitute_and_fold_engine::replace_uses_in):
Renamed from replace_uses_in. Call the virtual member function
(substitute_and_fold_engine::replace_phi_args_in): Similarly.
(substitute_and_fold_dom_walker): Remove initialization of
data member entries for calbacks. Add substitute_and_fold_engine
member and initialize it.
(substitute_and_fold_dom_walker::before_dom_children0: Use the
member functions for get_value, replace_phi_args_in c
replace_uses_in, and fold_stmt calls.
(substitute_and_fold_engine::substitute_and_fold): Renamed from
substitute_and_fold. Remove assert. Update ctor call.
From-SVN: r254330
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index ca5e969..63ee156 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -10530,10 +10530,17 @@ fold_predicate_in (gimple_stmt_iterator *si) return false; } +class vrp_folder : public substitute_and_fold_engine +{ + public: + tree get_value (tree) FINAL OVERRIDE; + bool fold_stmt (gimple_stmt_iterator *) FINAL OVERRIDE; +}; + /* Callback for substitute_and_fold folding the stmt at *SI. */ -static bool -vrp_fold_stmt (gimple_stmt_iterator *si) +bool +vrp_folder::fold_stmt (gimple_stmt_iterator *si) { if (fold_predicate_in (si)) return true; @@ -10541,6 +10548,18 @@ vrp_fold_stmt (gimple_stmt_iterator *si) return simplify_stmt_using_ranges (si); } +/* If OP has a value range with a single constant value return that, + otherwise return NULL_TREE. This returns OP itself if OP is a + constant. + + Implemented as a pure wrapper right now, but this will change. */ + +tree +vrp_folder::get_value (tree op) +{ + return op_with_constant_singleton_value_range (op); +} + /* Return the LHS of any ASSERT_EXPR where OP appears as the first argument to the ASSERT_EXPR and in which the ASSERT_EXPR dominates BB. If no such ASSERT_EXPR is found, return OP. */ @@ -10882,7 +10901,8 @@ vrp_finalize (bool warn_array_bounds_p) wi::to_wide (vr_value[i]->max)); } - substitute_and_fold (op_with_constant_singleton_value_range, vrp_fold_stmt); + class vrp_folder vrp_folder; + vrp_folder.substitute_and_fold (); if (warn_array_bounds && warn_array_bounds_p) check_all_array_refs (); @@ -11219,8 +11239,8 @@ evrp_dom_walker::before_dom_children (basic_block bb) } /* Try folding stmts with the VR discovered. */ - bool did_replace - = replace_uses_in (stmt, op_with_constant_singleton_value_range); + class vrp_folder vrp_folder; + bool did_replace = vrp_folder.replace_uses_in (stmt); if (fold_stmt (&gsi, follow_single_use_edges) || did_replace) { |