
This moves all the simplification code from vr_values into a separate class (simplify_using_ranges). In doing so, we get rid of a bunch of dependencies on the internals of vr_values. The goal is to (a) remove unnecessary interdependendcies (b) be able to use this engine with any range infrastructure, as all it needs is a method to get the range for an SSA name (get_value_range). I also removed as many dependencies on value_range_equiv as possible, preferring value_range. A few value_range_equiv uses remain, but for cases where equivalences are actually used (folding conditionals, etc). gcc/ChangeLog: * gimple-ssa-evrp-analyze.h (vrp_visit_cond_stmt): Use simplify_using_ranges class. * gimple-ssa-evrp.c (class evrp_folder): New simplify_using_ranges field. Adjust all methods to use new field. * tree-ssa-dom.c (simplify_stmt_for_jump_threading): Use simplify_using_ranges class. * tree-vrp.c (class vrp_folder): New simplify_using_ranges field. Adjust all methods to use new field. (simplify_stmt_for_jump_threading): Use simplify_using_ranges class. (vrp_prop::vrp_finalize): New vrp_folder argument. (execute_vrp): Pass folder to vrp_finalize. Use simplify_using_ranges class. Remove cleanup_edges_and_switches call. * vr-values.c (vr_values::op_with_boolean_value_range_p): Change value_range_equiv uses to value_range. (simplify_using_ranges::op_with_boolean_value_range_p): Use simplify_using_ranges class. (check_for_binary_op_overflow): Make static. (vr_values::extract_range_basic): Pass this to check_for_binary_op_overflow. (compare_range_with_value): Change value_range_equiv uses to value_range. (vr_values::vr_values): Initialize simplifier field. Remove uses of to_remove_edges and to_update_switch_stmts. (vr_values::~vr_values): Remove uses of to_remove_edges and to_update_switch_stmts. (vr_values::get_vr_for_comparison): Move to simplify_using_ranges class. (vr_values::compare_name_with_value): Same. (vr_values::compare_names): Same. (vr_values::vrp_evaluate_conditional_warnv_with_ops): Same. (vr_values::vrp_evaluate_conditional): Same. (vr_values::vrp_visit_cond_stmt): Same. (find_case_label_ranges): Change value_range_equiv uses to value_range. (vr_values::extract_range_from_stmt): Use simplify_using_ranges class. (vr_values::simplify_truth_ops_using_ranges): Move to simplify_using_ranges class. (vr_values::simplify_div_or_mod_using_ranges): Same. (vr_values::simplify_min_or_max_using_ranges): Same. (vr_values::simplify_abs_using_ranges): Same. (vr_values::simplify_bit_ops_using_ranges): Same. (test_for_singularity): Change value_range_equiv uses to value_range. (range_fits_type_p): Same. (vr_values::simplify_cond_using_ranges_1): Same. (vr_values::simplify_cond_using_ranges_2): Make extern. (vr_values::fold_cond): Move to simplify_using_ranges class. (vr_values::simplify_switch_using_ranges): Same. (vr_values::cleanup_edges_and_switches): Same. (vr_values::simplify_float_conversion_using_ranges): Same. (vr_values::simplify_internal_call_using_ranges): Same. (vr_values::two_valued_val_range_p): Same. (vr_values::simplify_stmt_using_ranges): Move to... (simplify_using_ranges::simplify): ...here. * vr-values.h (class vr_values): Move all the simplification of statements using ranges methods and code from here... (class simplify_using_ranges): ...to here. (simplify_cond_using_ranges_2): New extern prototype.
82 lines
2.6 KiB
C++
82 lines
2.6 KiB
C++
/* Support routines for Value Range Propagation (VRP).
|
|
Copyright (C) 2016-2020 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_GIMPLE_SSA_EVRP_ANALYZE_H
|
|
#define GCC_GIMPLE_SSA_EVRP_ANALYZE_H
|
|
|
|
class evrp_range_analyzer
|
|
{
|
|
public:
|
|
evrp_range_analyzer (bool update_global_ranges);
|
|
~evrp_range_analyzer (void)
|
|
{
|
|
delete vr_values;
|
|
stack.release ();
|
|
}
|
|
|
|
void enter (basic_block);
|
|
void push_marker (void);
|
|
void pop_to_marker (void);
|
|
void leave (basic_block);
|
|
void record_ranges_from_stmt (gimple *, bool);
|
|
|
|
/* Main interface to retrieve range information. */
|
|
const value_range_equiv *get_value_range (const_tree op)
|
|
{ return vr_values->get_value_range (op); }
|
|
|
|
/* Record a new unwindable range. */
|
|
void push_value_range (tree var, value_range_equiv *vr);
|
|
|
|
/* Dump all the current value ranges. This is primarily
|
|
a debugging interface. */
|
|
void dump_all_value_ranges (FILE *fp)
|
|
{ vr_values->dump_all_value_ranges (fp); }
|
|
|
|
/* A bit of a wart. This should ideally go away. */
|
|
void vrp_visit_cond_stmt (gcond *cond, edge *e)
|
|
{
|
|
simplify_using_ranges simpl (vr_values);
|
|
simpl.vrp_visit_cond_stmt (cond, e);
|
|
}
|
|
|
|
/* Get the underlying vr_values class instance. If TRANSFER is
|
|
true, then we are transferring ownership. Else we keep ownership.
|
|
|
|
This should be converted to a unique_ptr. */
|
|
class vr_values *get_vr_values (void) { return vr_values; }
|
|
|
|
private:
|
|
DISABLE_COPY_AND_ASSIGN (evrp_range_analyzer);
|
|
class vr_values *vr_values;
|
|
|
|
void pop_value_range ();
|
|
value_range_equiv *try_find_new_range (tree, tree op, tree_code code,
|
|
tree limit);
|
|
void record_ranges_from_incoming_edge (basic_block);
|
|
void record_ranges_from_phis (basic_block);
|
|
void set_ssa_range_info (tree, value_range_equiv *);
|
|
|
|
/* STACK holds the old VR. */
|
|
auto_vec<std::pair <tree, value_range_equiv *> > stack;
|
|
|
|
/* True if we are updating global ranges, false otherwise. */
|
|
bool m_update_global_ranges;
|
|
};
|
|
|
|
#endif /* GCC_GIMPLE_SSA_EVRP_ANALYZE_H */
|