Commit d9256277 by Richard Guenther Committed by Richard Biener

tree-vrp.c (num_vr_values, [...]): New global vars.

2011-07-25  Richard Guenther  <rguenther@suse.de>

	* tree-vrp.c (num_vr_values, values_propagated): New global vars.
	(get_value_range): For out-of-range SSA names or names created
	after propagation return a read-only varying range.
	(dump_all_value_ranges): Adjust.
	(vrp_initialize): Likewise.
	(vrp_finalize): Likewise.

From-SVN: r176734
parent 3bb4eb1c
2011-07-25 Richard Guenther <rguenther@suse.de>
* tree-vrp.c (num_vr_values, values_propagated): New global vars.
(get_value_range): For out-of-range SSA names or names created
after propagation return a read-only varying range.
(dump_all_value_ranges): Adjust.
(vrp_initialize): Likewise.
(vrp_finalize): Likewise.
2011-07-24 Richard Henderson <rth@redhat.com> 2011-07-24 Richard Henderson <rth@redhat.com>
PR debug/49831 PR debug/49831
......
...@@ -138,7 +138,9 @@ static assert_locus_t *asserts_for; ...@@ -138,7 +138,9 @@ static assert_locus_t *asserts_for;
/* Value range array. After propagation, VR_VALUE[I] holds the range /* Value range array. After propagation, VR_VALUE[I] holds the range
of values that SSA name N_I may take. */ of values that SSA name N_I may take. */
static unsigned num_vr_values;
static value_range_t **vr_value; static value_range_t **vr_value;
static bool values_propagated;
/* For a PHI node which sets SSA name N_I, VR_COUNTS[I] holds the /* For a PHI node which sets SSA name N_I, VR_COUNTS[I] holds the
number of executable edges we saw the last time we visited the number of executable edges we saw the last time we visited the
...@@ -658,6 +660,8 @@ abs_extent_range (value_range_t *vr, tree min, tree max) ...@@ -658,6 +660,8 @@ abs_extent_range (value_range_t *vr, tree min, tree max)
static value_range_t * static value_range_t *
get_value_range (const_tree var) get_value_range (const_tree var)
{ {
static const struct value_range_d vr_const_varying
= { VR_VARYING, NULL_TREE, NULL_TREE, NULL };
value_range_t *vr; value_range_t *vr;
tree sym; tree sym;
unsigned ver = SSA_NAME_VERSION (var); unsigned ver = SSA_NAME_VERSION (var);
...@@ -666,10 +670,20 @@ get_value_range (const_tree var) ...@@ -666,10 +670,20 @@ get_value_range (const_tree var)
if (! vr_value) if (! vr_value)
return NULL; return NULL;
/* If we query the range for a new SSA name return an unmodifiable VARYING.
We should get here at most from the substitute-and-fold stage which
will never try to change values. */
if (ver >= num_vr_values)
return CONST_CAST (value_range_t *, &vr_const_varying);
vr = vr_value[ver]; vr = vr_value[ver];
if (vr) if (vr)
return vr; return vr;
/* After propagation finished do not allocate new value-ranges. */
if (values_propagated)
return CONST_CAST (value_range_t *, &vr_const_varying);
/* Create a default value range. */ /* Create a default value range. */
vr_value[ver] = vr = XCNEW (value_range_t); vr_value[ver] = vr = XCNEW (value_range_t);
...@@ -3931,7 +3945,7 @@ dump_all_value_ranges (FILE *file) ...@@ -3931,7 +3945,7 @@ dump_all_value_ranges (FILE *file)
{ {
size_t i; size_t i;
for (i = 0; i < num_ssa_names; i++) for (i = 0; i < num_vr_values; i++)
{ {
if (vr_value[i]) if (vr_value[i])
{ {
...@@ -5593,7 +5607,9 @@ vrp_initialize (void) ...@@ -5593,7 +5607,9 @@ vrp_initialize (void)
{ {
basic_block bb; basic_block bb;
vr_value = XCNEWVEC (value_range_t *, num_ssa_names); values_propagated = false;
num_vr_values = num_ssa_names;
vr_value = XCNEWVEC (value_range_t *, num_vr_values);
vr_phi_edge_counts = XCNEWVEC (int, num_ssa_names); vr_phi_edge_counts = XCNEWVEC (int, num_ssa_names);
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
...@@ -5720,7 +5736,7 @@ vrp_visit_assignment_or_call (gimple stmt, tree *output_p) ...@@ -5720,7 +5736,7 @@ vrp_visit_assignment_or_call (gimple stmt, tree *output_p)
static inline value_range_t static inline value_range_t
get_vr_for_comparison (int i) get_vr_for_comparison (int i)
{ {
value_range_t vr = *(vr_value[i]); value_range_t vr = *get_value_range (ssa_name (i));
/* If name N_i does not have a valid range, use N_i as its own /* If name N_i does not have a valid range, use N_i as its own
range. This allows us to compare against names that may range. This allows us to compare against names that may
...@@ -7700,7 +7716,8 @@ static void ...@@ -7700,7 +7716,8 @@ static void
vrp_finalize (void) vrp_finalize (void)
{ {
size_t i; size_t i;
unsigned num = num_ssa_names;
values_propagated = true;
if (dump_file) if (dump_file)
{ {
...@@ -7720,7 +7737,7 @@ vrp_finalize (void) ...@@ -7720,7 +7737,7 @@ vrp_finalize (void)
identify_jump_threads (); identify_jump_threads ();
/* Free allocated memory. */ /* Free allocated memory. */
for (i = 0; i < num; i++) for (i = 0; i < num_vr_values; i++)
if (vr_value[i]) if (vr_value[i])
{ {
BITMAP_FREE (vr_value[i]->equiv); BITMAP_FREE (vr_value[i]->equiv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment