diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 5b74681b61a..3c819933c4e 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -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"); }