testsuite: remove SPE tests.
[official-gcc.git] / gcc / vr-values.h
blob62a20218c6d16a0a787b06652e3653d63813321c
1 /* Support routines for Value Range Propagation (VRP).
2 Copyright (C) 2016-2020 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_VR_VALUES_H
21 #define GCC_VR_VALUES_H
23 #include "value-range-equiv.h"
25 // Class to simplify a statement using range information.
27 // The constructor takes a full vr_values, but all it needs is
28 // get_value_range() from it. This class could be made to work with
29 // any range repository.
31 class simplify_using_ranges
33 public:
34 simplify_using_ranges (class vr_values *);
35 ~simplify_using_ranges ();
36 bool simplify (gimple_stmt_iterator *);
38 // ?? These should be cleaned, merged, and made private.
39 tree vrp_evaluate_conditional (tree_code, tree, tree, gimple *);
40 void vrp_visit_cond_stmt (gcond *, edge *);
41 tree vrp_evaluate_conditional_warnv_with_ops (enum tree_code,
42 tree, tree, bool,
43 bool *, bool *);
45 private:
46 const value_range_equiv *get_value_range (const_tree op);
47 bool simplify_truth_ops_using_ranges (gimple_stmt_iterator *, gimple *);
48 bool simplify_div_or_mod_using_ranges (gimple_stmt_iterator *, gimple *);
49 bool simplify_abs_using_ranges (gimple_stmt_iterator *, gimple *);
50 bool simplify_bit_ops_using_ranges (gimple_stmt_iterator *, gimple *);
51 bool simplify_min_or_max_using_ranges (gimple_stmt_iterator *, gimple *);
52 bool simplify_cond_using_ranges_1 (gcond *);
53 bool fold_cond (gcond *);
54 bool simplify_switch_using_ranges (gswitch *);
55 bool simplify_float_conversion_using_ranges (gimple_stmt_iterator *,
56 gimple *);
57 bool simplify_internal_call_using_ranges (gimple_stmt_iterator *, gimple *);
59 bool two_valued_val_range_p (tree, tree *, tree *);
60 bool op_with_boolean_value_range_p (tree);
61 tree compare_name_with_value (enum tree_code, tree, tree, bool *, bool);
62 tree compare_names (enum tree_code, tree, tree, bool *);
63 const value_range_equiv *get_vr_for_comparison (int, value_range_equiv *);
64 tree vrp_evaluate_conditional_warnv_with_ops_using_ranges (enum tree_code,
65 tree, tree,
66 bool *);
67 void cleanup_edges_and_switches (void);
69 /* Vectors of edges that need removing and switch statements that
70 need updating. It is expected that a pass using the simplification
71 routines will, at the end of the pass, clean up the edges and
72 switch statements. The class dtor will try to detect cases
73 that do not follow that expectation. */
74 struct switch_update {
75 gswitch *stmt;
76 tree vec;
79 vec<edge> to_remove_edges;
80 vec<switch_update> to_update_switch_stmts;
81 class vr_values *store;
84 /* The VR_VALUES class holds the current view of range information
85 for all the SSA_NAMEs in the IL.
87 It can be used to hold context sensitive range information during
88 a dominator walk or it may be used to hold range information in the
89 standard VRP pass as ranges are propagated through the lattice to a
90 steady state.
92 This information is independent of the range information that gets
93 attached to SSA_NAMEs. A pass such as VRP may choose to transfer
94 the global information it produces into global range information that
95 gets attached to an SSA_NAME. It's unclear how useful that global
96 information will be in a world where we can compute context sensitive
97 range information fast or perform on-demand queries. */
98 class vr_values
100 public:
101 vr_values (void);
102 ~vr_values (void);
104 const value_range_equiv *get_value_range (const_tree);
105 void set_vr_value (tree, value_range_equiv *);
106 value_range_equiv *swap_vr_value (tree, value_range_equiv *);
108 void set_def_to_varying (const_tree);
109 void set_defs_to_varying (gimple *);
110 bool update_value_range (const_tree, value_range_equiv *);
111 tree op_with_constant_singleton_value_range (tree);
112 void adjust_range_with_scev (value_range_equiv *, class loop *,
113 gimple *, tree);
114 void dump_all_value_ranges (FILE *);
116 void extract_range_for_var_from_comparison_expr (tree, enum tree_code,
117 tree, tree,
118 value_range_equiv *);
119 void extract_range_from_phi_node (gphi *, value_range_equiv *);
120 void extract_range_basic (value_range_equiv *, gimple *);
121 void extract_range_from_stmt (gimple *, edge *, tree *, value_range_equiv *);
123 /* Indicate that propagation through the lattice is complete. */
124 void set_lattice_propagation_complete (void) { values_propagated = true; }
126 /* Allocate a new value_range object. */
127 value_range_equiv *allocate_value_range_equiv (void)
128 { return vrp_value_range_pool.allocate (); }
129 void free_value_range (value_range_equiv *vr)
130 { vrp_value_range_pool.remove (vr); }
132 private:
133 value_range_equiv *get_lattice_entry (const_tree);
134 bool vrp_stmt_computes_nonzero (gimple *);
135 void extract_range_from_assignment (value_range_equiv *, gassign *);
136 void extract_range_from_assert (value_range_equiv *, tree);
137 void extract_range_from_ssa_name (value_range_equiv *, tree);
138 void extract_range_from_binary_expr (value_range_equiv *, enum tree_code,
139 tree, tree, tree);
140 void extract_range_from_unary_expr (value_range_equiv *, enum tree_code,
141 tree, tree);
142 void extract_range_from_cond_expr (value_range_equiv *, gassign *);
143 void extract_range_from_comparison (value_range_equiv *, enum tree_code,
144 tree, tree, tree);
145 void vrp_visit_assignment_or_call (gimple*, tree *, value_range_equiv *);
146 void vrp_visit_switch_stmt (gswitch *, edge *);
148 /* Allocation pools for value_range objects. */
149 object_allocator<value_range_equiv> vrp_value_range_pool;
151 /* This probably belongs in the lattice rather than in here. */
152 bool values_propagated;
154 /* Allocations for equivalences all come from this obstack. */
155 bitmap_obstack vrp_equiv_obstack;
157 /* Value range array. After propagation, VR_VALUE[I] holds the range
158 of values that SSA name N_I may take. */
159 unsigned int num_vr_values;
160 value_range_equiv **vr_value;
162 /* For a PHI node which sets SSA name N_I, VR_COUNTS[I] holds the
163 number of executable edges we saw the last time we visited the
164 node. */
165 int *vr_phi_edge_counts;
166 simplify_using_ranges simplifier;
169 inline const value_range_equiv *
170 simplify_using_ranges::get_value_range (const_tree op)
172 return store->get_value_range (op);
175 extern tree get_output_for_vrp (gimple *);
177 // FIXME: Move this to tree-vrp.c.
178 void simplify_cond_using_ranges_2 (class vr_values *, gcond *);
180 #endif /* GCC_VR_VALUES_H */