+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>
PR debug/49831
/* Value range array. After propagation, VR_VALUE[I] holds the range
of values that SSA name N_I may take. */
+static unsigned num_vr_values;
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
number of executable edges we saw the last time we visited the
static value_range_t *
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;
tree sym;
unsigned ver = SSA_NAME_VERSION (var);
if (! vr_value)
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];
if (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. */
vr_value[ver] = vr = XCNEW (value_range_t);
{
size_t i;
- for (i = 0; i < num_ssa_names; i++)
+ for (i = 0; i < num_vr_values; i++)
{
if (vr_value[i])
{
{
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);
FOR_EACH_BB (bb)
static inline value_range_t
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
range. This allows us to compare against names that may
vrp_finalize (void)
{
size_t i;
- unsigned num = num_ssa_names;
+
+ values_propagated = true;
if (dump_file)
{
identify_jump_threads ();
/* Free allocated memory. */
- for (i = 0; i < num; i++)
+ for (i = 0; i < num_vr_values; i++)
if (vr_value[i])
{
BITMAP_FREE (vr_value[i]->equiv);