}
// 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)
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.
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);
}
}
- if (!print_header)
- fputc ('\n', f);
}
// Return true if NAME has an active range in the cache.
}
// 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)
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.
void
ranger_cache::dump (FILE *f)
{
+ fprintf (f, "Non-varying global ranges:\n");
+ fprintf (f, "=========================:\n");
m_globals.dump (f);
fprintf (f, "\n");
}