Tweak merge_range API.
merge_range use to return TRUE if there was already a range. Now it returns TRUE if a new range is added, OR updates and existing range with a new value. FALSE is returned when the range already matches. * gimple-range-cache.cc (ssa_cache::merge_range): Change meaning of the return value. (ssa_cache::dump): Don't print GLOBAL RANGE header. (ssa_lazy_cache::merge_range): Adjust return value meaning. (ranger_cache::dump): Print GLOBAL RANGE header.
This commit is contained in:
parent
0a59ff65df
commit
b512d70579
1 changed files with 15 additions and 24 deletions
|
@ -606,7 +606,7 @@ ssa_cache::set_range (tree name, const vrange &r)
|
|||
}
|
||||
|
||||
// If NAME has a range, intersect it with R, otherwise set it to R.
|
||||
// Return TRUE if there was already a range set, otherwise false.
|
||||
// Return TRUE if the range is new or changes.
|
||||
|
||||
bool
|
||||
ssa_cache::merge_range (tree name, const vrange &r)
|
||||
|
@ -616,19 +616,23 @@ ssa_cache::merge_range (tree name, const vrange &r)
|
|||
m_tab.safe_grow_cleared (num_ssa_names + 1);
|
||||
|
||||
vrange_storage *m = m_tab[v];
|
||||
if (m)
|
||||
// Check if this is a new value.
|
||||
if (!m)
|
||||
m_tab[v] = m_range_allocator->clone (r);
|
||||
else
|
||||
{
|
||||
Value_Range curr (TREE_TYPE (name));
|
||||
m->get_vrange (curr, TREE_TYPE (name));
|
||||
curr.intersect (r);
|
||||
// If there is no change, return false.
|
||||
if (!curr.intersect (r))
|
||||
return false;
|
||||
|
||||
if (m->fits_p (curr))
|
||||
m->set_vrange (curr);
|
||||
else
|
||||
m_tab[v] = m_range_allocator->clone (curr);
|
||||
}
|
||||
else
|
||||
m_tab[v] = m_range_allocator->clone (r);
|
||||
return m != NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set the range for NAME to R in the ssa cache.
|
||||
|
@ -656,27 +660,14 @@ ssa_cache::clear ()
|
|||
void
|
||||
ssa_cache::dump (FILE *f)
|
||||
{
|
||||
/* Cleared after the table header has been printed. */
|
||||
bool print_header = true;
|
||||
for (unsigned x = 1; x < num_ssa_names; x++)
|
||||
{
|
||||
if (!gimple_range_ssa_p (ssa_name (x)))
|
||||
continue;
|
||||
Value_Range r (TREE_TYPE (ssa_name (x)));
|
||||
// Invoke dump_range_query which is a private virtual version of
|
||||
// get_range. This avoids performance impacts on general queries,
|
||||
// but allows sharing of the dump routine.
|
||||
// Dump all non-varying ranges.
|
||||
if (get_range (r, ssa_name (x)) && !r.varying_p ())
|
||||
{
|
||||
if (print_header)
|
||||
{
|
||||
/* Print the header only when there's something else
|
||||
to print below. */
|
||||
fprintf (f, "Non-varying global ranges:\n");
|
||||
fprintf (f, "=========================:\n");
|
||||
print_header = false;
|
||||
}
|
||||
|
||||
print_generic_expr (f, ssa_name (x), TDF_NONE);
|
||||
fprintf (f, " : ");
|
||||
r.dump (f);
|
||||
|
@ -684,8 +675,6 @@ ssa_cache::dump (FILE *f)
|
|||
}
|
||||
}
|
||||
|
||||
if (!print_header)
|
||||
fputc ('\n', f);
|
||||
}
|
||||
|
||||
// Return true if NAME has an active range in the cache.
|
||||
|
@ -716,7 +705,7 @@ ssa_lazy_cache::set_range (tree name, const vrange &r)
|
|||
}
|
||||
|
||||
// If NAME has a range, intersect it with R, otherwise set it to R.
|
||||
// Return TRUE if there was already a range set, otherwise false.
|
||||
// Return TRUE if the range is new or changes.
|
||||
|
||||
bool
|
||||
ssa_lazy_cache::merge_range (tree name, const vrange &r)
|
||||
|
@ -731,7 +720,7 @@ ssa_lazy_cache::merge_range (tree name, const vrange &r)
|
|||
if (v >= m_tab.length ())
|
||||
m_tab.safe_grow (num_ssa_names + 1);
|
||||
m_tab[v] = m_range_allocator->clone (r);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return TRUE if NAME has a range, and return it in R.
|
||||
|
@ -996,6 +985,8 @@ ranger_cache::~ranger_cache ()
|
|||
void
|
||||
ranger_cache::dump (FILE *f)
|
||||
{
|
||||
fprintf (f, "Non-varying global ranges:\n");
|
||||
fprintf (f, "=========================:\n");
|
||||
m_globals.dump (f);
|
||||
fprintf (f, "\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue