public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-4184] Tweak merge_range API.
@ 2023-09-20 19:29 Andrew Macleod
0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2023-09-20 19:29 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b512d705797a65dbfe3a9ad100218192c7528b02
commit r14-4184-gb512d705797a65dbfe3a9ad100218192c7528b02
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Wed Sep 20 12:53:04 2023 -0400
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.
Diff:
---
gcc/gimple-range-cache.cc | 39 +++++++++++++++------------------------
1 file changed, 15 insertions(+), 24 deletions(-)
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");
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-20 19:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-20 19:29 [gcc r14-4184] Tweak merge_range API Andrew Macleod
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).