]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/vr-values.h
[testsuite] Add missing dg-require-effective-target label_values
[thirdparty/gcc.git] / gcc / vr-values.h
CommitLineData
8302eff5 1/* Support routines for Value Range Propagation (VRP).
fbd26352 2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
8302eff5 3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 3, or (at your option)
9any later version.
10
11GCC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along 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
23/* The VR_VALUES class holds the current view of range information
24 for all the SSA_NAMEs in the IL.
25
26 It can be used to hold context sensitive range information during
27 a dominator walk or it may be used to hold range information in the
28 standard VRP pass as ranges are propagated through the lattice to a
29 steady state.
30
31 This information is independent of the range information that gets
32 attached to SSA_NAMEs. A pass such as VRP may choose to transfer
33 the global information it produces into global range information that
34 gets attached to an SSA_NAME. It's unclear how useful that global
35 information will be in a world where we can compute context sensitive
36 range information fast or perform on-demand queries. */
37class vr_values
38{
39 public:
40 vr_values (void);
41 ~vr_values (void);
42
c561e1e7 43 value_range *get_value_range (const_tree);
8302eff5 44
c561e1e7 45 void set_vr_value (tree, value_range *);
46 void set_defs_to_varying (gimple *);
47 bool update_value_range (const_tree, value_range *);
48 tree op_with_constant_singleton_value_range (tree);
49 void adjust_range_with_scev (value_range *, struct loop *, gimple *, tree);
50 tree vrp_evaluate_conditional (tree_code, tree, tree, gimple *);
51 void dump_all_value_ranges (FILE *);
52
53 void extract_range_for_var_from_comparison_expr (tree, enum tree_code,
54 tree, tree, value_range *);
55 void extract_range_from_phi_node (gphi *, value_range *);
56 void extract_range_basic (value_range *, gimple *);
c561e1e7 57 void extract_range_from_stmt (gimple *, edge *, tree *, value_range *);
58
59 void vrp_visit_cond_stmt (gcond *, edge *);
60
61 void simplify_cond_using_ranges_2 (gcond *);
62 bool simplify_stmt_using_ranges (gimple_stmt_iterator *);
63
2e1f26dd 64 /* Indicate that propagation through the lattice is complete. */
65 void set_lattice_propagation_complete (void) { values_propagated = true; }
8302eff5 66
2e1f26dd 67 /* Allocate a new value_range object. */
68 value_range *allocate_value_range (void)
69 { return vrp_value_range_pool.allocate (); }
8302eff5 70
d443f534 71 /* */
72 void cleanup_edges_and_switches (void);
73
c561e1e7 74 private:
8302eff5 75 bool vrp_stmt_computes_nonzero (gimple *);
8302eff5 76 bool op_with_boolean_value_range_p (tree);
77 bool check_for_binary_op_overflow (enum tree_code, tree, tree, tree, bool *);
48625f58 78 value_range *get_vr_for_comparison (int, value_range *);
8302eff5 79 tree compare_name_with_value (enum tree_code, tree, tree, bool *, bool);
80 tree compare_names (enum tree_code, tree, tree, bool *);
81 bool two_valued_val_range_p (tree, tree *, tree *);
8302eff5 82 tree vrp_evaluate_conditional_warnv_with_ops_using_ranges (enum tree_code,
83 tree, tree,
84 bool *);
85 tree vrp_evaluate_conditional_warnv_with_ops (enum tree_code,
86 tree, tree, bool,
87 bool *, bool *);
2e1f26dd 88 void extract_range_from_assignment (value_range *, gassign *);
8302eff5 89 void extract_range_from_assert (value_range *, tree);
90 void extract_range_from_ssa_name (value_range *, tree);
91 void extract_range_from_binary_expr (value_range *, enum tree_code,
92 tree, tree, tree);
93 void extract_range_from_unary_expr (value_range *, enum tree_code,
94 tree, tree);
8302eff5 95 void extract_range_from_cond_expr (value_range *, gassign *);
8302eff5 96 void extract_range_from_comparison (value_range *, enum tree_code,
97 tree, tree, tree);
8302eff5 98 void vrp_visit_assignment_or_call (gimple*, tree *, value_range *);
99 void vrp_visit_switch_stmt (gswitch *, edge *);
8302eff5 100 bool simplify_truth_ops_using_ranges (gimple_stmt_iterator *, gimple *);
101 bool simplify_div_or_mod_using_ranges (gimple_stmt_iterator *, gimple *);
102 bool simplify_abs_using_ranges (gimple_stmt_iterator *, gimple *);
103 bool simplify_bit_ops_using_ranges (gimple_stmt_iterator *, gimple *);
104 bool simplify_min_or_max_using_ranges (gimple_stmt_iterator *, gimple *);
105 bool simplify_cond_using_ranges_1 (gcond *);
8302eff5 106 bool simplify_switch_using_ranges (gswitch *);
107 bool simplify_float_conversion_using_ranges (gimple_stmt_iterator *,
108 gimple *);
109 bool simplify_internal_call_using_ranges (gimple_stmt_iterator *, gimple *);
c561e1e7 110
2e1f26dd 111 /* Allocation pools for value_range objects. */
112 object_allocator<value_range> vrp_value_range_pool;
113
114 /* This probably belongs in the lattice rather than in here. */
115 bool values_propagated;
116
117 /* Allocations for equivalences all come from this obstack. */
118 bitmap_obstack vrp_equiv_obstack;
119
c561e1e7 120 /* Value range array. After propagation, VR_VALUE[I] holds the range
121 of values that SSA name N_I may take. */
122 unsigned int num_vr_values;
123 value_range **vr_value;
124
125 /* For a PHI node which sets SSA name N_I, VR_COUNTS[I] holds the
126 number of executable edges we saw the last time we visited the
127 node. */
128 int *vr_phi_edge_counts;
d443f534 129
130 /* Vectors of edges that need removing and switch statements that
131 need updating. It is expected that a pass using the simplification
132 routines will, at the end of the pass, clean up the edges and
133 switch statements. The class dtor will try to detect cases
134 that do not follow that expectation. */
135 struct switch_update {
136 gswitch *stmt;
137 tree vec;
138 };
139
140 vec<edge> to_remove_edges;
141 vec<switch_update> to_update_switch_stmts;
8302eff5 142};
143
46bc42c6 144extern tree get_output_for_vrp (gimple *);
8302eff5 145#endif /* GCC_VR_VALUES_H */