summaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2010-08-04 12:29:48 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2010-08-04 12:29:48 +0000
commit455e6d5ba7c8c2501cad22f3ecee229cc130b87f (patch)
tree44d87dd02a78032816f3cb81e0405f29ab9570c6 /gcc/tree-vrp.c
parenta48a91732b5252f6be1f0b3d54bfb1da52947caf (diff)
downloadgcc-455e6d5ba7c8c2501cad22f3ecee229cc130b87f.tar.gz
tree-ssa-propagate.h (struct prop_value_d, [...]): Move ...
2010-08-04 Richard Guenther <rguenther@suse.de> * tree-ssa-propagate.h (struct prop_value_d, prop_value_t): Move ... * tree-ssa-ccp.c: ... here. * tree-ssa-copy.c: ... and here. * tree-ssa-propagate.h (enum value_range_type, struct value_range_d, value_range_t): Move ... * tree-vrp.c: ... here. * tree-ssa-propagate.h (ssa_prop_get_value_fn): New typedef. (substitute_and_fold): Adjust prototype. * tree-ssa-propagate.c (replace_uses_in): Adjust. (replace_phi_args_in): Likewise. (substitute_and_fold): Take callback to query lattice instead of pointer to lattice. Replace SSA name defs with lattice values first. * tree-ssa-ccp.c (ccp_finalize): Adjust. * tree-ssa-copy.c (copy_prop_visit_phi_node): Adjust. (get_value): New function. (fini_copy_prop): Adjust. * tree-vrp.c (vrp_finalize): Adjust. * gcc.dg/tree-ssa/vrp35.c: Adjust. * gcc.dg/tree-ssa/vrp36.c: Likewise. * gcc.dg/tree-ssa/vrp50.c: Likewise. * gcc.dg/tree-ssa/vrp52.c: Likewise. From-SVN: r162864
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r--gcc/tree-vrp.c62
1 files changed, 34 insertions, 28 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 05fa186ecbe..35d12b309dd 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -42,6 +42,38 @@ along with GCC; see the file COPYING3. If not see
#include "tree-chrec.h"
+/* Type of value ranges. See value_range_d for a description of these
+ types. */
+enum value_range_type { VR_UNDEFINED, VR_RANGE, VR_ANTI_RANGE, VR_VARYING };
+
+/* Range of values that can be associated with an SSA_NAME after VRP
+ has executed. */
+struct value_range_d
+{
+ /* Lattice value represented by this range. */
+ enum value_range_type type;
+
+ /* Minimum and maximum values represented by this range. These
+ values should be interpreted as follows:
+
+ - If TYPE is VR_UNDEFINED or VR_VARYING then MIN and MAX must
+ be NULL.
+
+ - If TYPE == VR_RANGE then MIN holds the minimum value and
+ MAX holds the maximum value of the range [MIN, MAX].
+
+ - If TYPE == ANTI_RANGE the variable is known to NOT
+ take any values in the range [MIN, MAX]. */
+ tree min;
+ tree max;
+
+ /* Set of SSA names whose value ranges are equivalent to this one.
+ This set is only valid when TYPE is VR_RANGE or VR_ANTI_RANGE. */
+ bitmap equiv;
+};
+
+typedef struct value_range_d value_range_t;
+
/* Set of SSA names found live during the RPO traversal of the function
for still active basic-blocks. */
static sbitmap *live;
@@ -7526,8 +7558,6 @@ static void
vrp_finalize (void)
{
size_t i;
- prop_value_t *single_val_range;
- bool do_value_subst_p;
unsigned num = num_ssa_names;
if (dump_file)
@@ -7537,31 +7567,8 @@ vrp_finalize (void)
fprintf (dump_file, "\n");
}
- /* We may have ended with ranges that have exactly one value. Those
- values can be substituted as any other const propagated
- value using substitute_and_fold. */
- single_val_range = XCNEWVEC (prop_value_t, num);
-
- do_value_subst_p = false;
- for (i = 0; i < num; i++)
- if (vr_value[i]
- && vr_value[i]->type == VR_RANGE
- && vr_value[i]->min == vr_value[i]->max
- && is_gimple_min_invariant (vr_value[i]->min))
- {
- single_val_range[i].value = vr_value[i]->min;
- do_value_subst_p = true;
- }
-
- if (!do_value_subst_p)
- {
- /* We found no single-valued ranges, don't waste time trying to
- do single value substitution in substitute_and_fold. */
- free (single_val_range);
- single_val_range = NULL;
- }
-
- substitute_and_fold (single_val_range, vrp_fold_stmt, false);
+ substitute_and_fold (op_with_constant_singleton_value_range,
+ vrp_fold_stmt, false);
if (warn_array_bounds)
check_all_array_refs ();
@@ -7578,7 +7585,6 @@ vrp_finalize (void)
free (vr_value[i]);
}
- free (single_val_range);
free (vr_value);
free (vr_phi_edge_counts);