]>
Commit | Line | Data |
---|---|---|
89759031 | 1 | /* Support routines for Value Range Propagation (VRP). |
8d9254fc | 2 | Copyright (C) 2016-2020 Free Software Foundation, Inc. |
89759031 JL |
3 | |
4 | This file is part of GCC. | |
5 | ||
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. | |
10 | ||
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. | |
15 | ||
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/>. */ | |
19 | ||
20 | #ifndef GCC_VR_VALUES_H | |
21 | #define GCC_VR_VALUES_H | |
22 | ||
4a5e9d00 AH |
23 | #include "value-range-equiv.h" |
24 | ||
89759031 JL |
25 | /* The VR_VALUES class holds the current view of range information |
26 | for all the SSA_NAMEs in the IL. | |
27 | ||
28 | It can be used to hold context sensitive range information during | |
29 | a dominator walk or it may be used to hold range information in the | |
30 | standard VRP pass as ranges are propagated through the lattice to a | |
31 | steady state. | |
32 | ||
33 | This information is independent of the range information that gets | |
34 | attached to SSA_NAMEs. A pass such as VRP may choose to transfer | |
35 | the global information it produces into global range information that | |
36 | gets attached to an SSA_NAME. It's unclear how useful that global | |
37 | information will be in a world where we can compute context sensitive | |
38 | range information fast or perform on-demand queries. */ | |
39 | class vr_values | |
40 | { | |
41 | public: | |
42 | vr_values (void); | |
43 | ~vr_values (void); | |
44 | ||
028d81b1 AH |
45 | const value_range_equiv *get_value_range (const_tree); |
46 | void set_vr_value (tree, value_range_equiv *); | |
47 | value_range_equiv *swap_vr_value (tree, value_range_equiv *); | |
f86c2e71 | 48 | |
0982acbe | 49 | void set_def_to_varying (const_tree); |
a5de02e9 | 50 | void set_defs_to_varying (gimple *); |
028d81b1 | 51 | bool update_value_range (const_tree, value_range_equiv *); |
a5de02e9 | 52 | tree op_with_constant_singleton_value_range (tree); |
028d81b1 AH |
53 | void adjust_range_with_scev (value_range_equiv *, class loop *, |
54 | gimple *, tree); | |
a5de02e9 JL |
55 | tree vrp_evaluate_conditional (tree_code, tree, tree, gimple *); |
56 | void dump_all_value_ranges (FILE *); | |
57 | ||
58 | void extract_range_for_var_from_comparison_expr (tree, enum tree_code, | |
028d81b1 AH |
59 | tree, tree, |
60 | value_range_equiv *); | |
61 | void extract_range_from_phi_node (gphi *, value_range_equiv *); | |
62 | void extract_range_basic (value_range_equiv *, gimple *); | |
63 | void extract_range_from_stmt (gimple *, edge *, tree *, value_range_equiv *); | |
a5de02e9 JL |
64 | |
65 | void vrp_visit_cond_stmt (gcond *, edge *); | |
66 | ||
67 | void simplify_cond_using_ranges_2 (gcond *); | |
68 | bool simplify_stmt_using_ranges (gimple_stmt_iterator *); | |
69 | ||
3e406d33 JL |
70 | /* Indicate that propagation through the lattice is complete. */ |
71 | void set_lattice_propagation_complete (void) { values_propagated = true; } | |
89759031 | 72 | |
3e406d33 | 73 | /* Allocate a new value_range object. */ |
028d81b1 | 74 | value_range_equiv *allocate_value_range_equiv (void) |
3e406d33 | 75 | { return vrp_value_range_pool.allocate (); } |
028d81b1 | 76 | void free_value_range (value_range_equiv *vr) |
f86c2e71 | 77 | { vrp_value_range_pool.remove (vr); } |
89759031 | 78 | |
35b66f30 JL |
79 | /* */ |
80 | void cleanup_edges_and_switches (void); | |
81 | ||
a5de02e9 | 82 | private: |
028d81b1 | 83 | value_range_equiv *get_lattice_entry (const_tree); |
89759031 | 84 | bool vrp_stmt_computes_nonzero (gimple *); |
89759031 JL |
85 | bool op_with_boolean_value_range_p (tree); |
86 | bool check_for_binary_op_overflow (enum tree_code, tree, tree, tree, bool *); | |
028d81b1 | 87 | const value_range_equiv *get_vr_for_comparison (int, value_range_equiv *); |
89759031 JL |
88 | tree compare_name_with_value (enum tree_code, tree, tree, bool *, bool); |
89 | tree compare_names (enum tree_code, tree, tree, bool *); | |
90 | bool two_valued_val_range_p (tree, tree *, tree *); | |
89759031 JL |
91 | tree vrp_evaluate_conditional_warnv_with_ops_using_ranges (enum tree_code, |
92 | tree, tree, | |
93 | bool *); | |
94 | tree vrp_evaluate_conditional_warnv_with_ops (enum tree_code, | |
95 | tree, tree, bool, | |
96 | bool *, bool *); | |
028d81b1 AH |
97 | void extract_range_from_assignment (value_range_equiv *, gassign *); |
98 | void extract_range_from_assert (value_range_equiv *, tree); | |
99 | void extract_range_from_ssa_name (value_range_equiv *, tree); | |
100 | void extract_range_from_binary_expr (value_range_equiv *, enum tree_code, | |
89759031 | 101 | tree, tree, tree); |
028d81b1 | 102 | void extract_range_from_unary_expr (value_range_equiv *, enum tree_code, |
89759031 | 103 | tree, tree); |
028d81b1 AH |
104 | void extract_range_from_cond_expr (value_range_equiv *, gassign *); |
105 | void extract_range_from_comparison (value_range_equiv *, enum tree_code, | |
89759031 | 106 | tree, tree, tree); |
028d81b1 | 107 | void vrp_visit_assignment_or_call (gimple*, tree *, value_range_equiv *); |
89759031 | 108 | void vrp_visit_switch_stmt (gswitch *, edge *); |
89759031 JL |
109 | bool simplify_truth_ops_using_ranges (gimple_stmt_iterator *, gimple *); |
110 | bool simplify_div_or_mod_using_ranges (gimple_stmt_iterator *, gimple *); | |
111 | bool simplify_abs_using_ranges (gimple_stmt_iterator *, gimple *); | |
112 | bool simplify_bit_ops_using_ranges (gimple_stmt_iterator *, gimple *); | |
113 | bool simplify_min_or_max_using_ranges (gimple_stmt_iterator *, gimple *); | |
114 | bool simplify_cond_using_ranges_1 (gcond *); | |
1396fa5b | 115 | bool fold_cond (gcond *); |
89759031 JL |
116 | bool simplify_switch_using_ranges (gswitch *); |
117 | bool simplify_float_conversion_using_ranges (gimple_stmt_iterator *, | |
118 | gimple *); | |
119 | bool simplify_internal_call_using_ranges (gimple_stmt_iterator *, gimple *); | |
a5de02e9 | 120 | |
3e406d33 | 121 | /* Allocation pools for value_range objects. */ |
028d81b1 | 122 | object_allocator<value_range_equiv> vrp_value_range_pool; |
3e406d33 JL |
123 | |
124 | /* This probably belongs in the lattice rather than in here. */ | |
125 | bool values_propagated; | |
126 | ||
127 | /* Allocations for equivalences all come from this obstack. */ | |
128 | bitmap_obstack vrp_equiv_obstack; | |
129 | ||
a5de02e9 JL |
130 | /* Value range array. After propagation, VR_VALUE[I] holds the range |
131 | of values that SSA name N_I may take. */ | |
132 | unsigned int num_vr_values; | |
028d81b1 | 133 | value_range_equiv **vr_value; |
a5de02e9 JL |
134 | |
135 | /* For a PHI node which sets SSA name N_I, VR_COUNTS[I] holds the | |
136 | number of executable edges we saw the last time we visited the | |
137 | node. */ | |
138 | int *vr_phi_edge_counts; | |
35b66f30 JL |
139 | |
140 | /* Vectors of edges that need removing and switch statements that | |
141 | need updating. It is expected that a pass using the simplification | |
142 | routines will, at the end of the pass, clean up the edges and | |
143 | switch statements. The class dtor will try to detect cases | |
144 | that do not follow that expectation. */ | |
145 | struct switch_update { | |
146 | gswitch *stmt; | |
147 | tree vec; | |
148 | }; | |
149 | ||
150 | vec<edge> to_remove_edges; | |
151 | vec<switch_update> to_update_switch_stmts; | |
89759031 JL |
152 | }; |
153 | ||
f432e4fc | 154 | extern tree get_output_for_vrp (gimple *); |
89759031 | 155 | #endif /* GCC_VR_VALUES_H */ |