aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-range-path.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/gimple-range-path.cc')
-rw-r--r--gcc/gimple-range-path.cc65
1 files changed, 14 insertions, 51 deletions
diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
index 07868df..7438b83 100644
--- a/gcc/gimple-range-path.cc
+++ b/gcc/gimple-range-path.cc
@@ -40,8 +40,7 @@ path_range_query::path_range_query (gimple_ranger &ranger,
const vec<basic_block> &path,
const bitmap_head *dependencies,
bool resolve)
- : m_cache (new ssa_cache),
- m_has_cache_entry (BITMAP_ALLOC (NULL)),
+ : m_cache (),
m_ranger (ranger),
m_resolve (resolve)
{
@@ -51,8 +50,7 @@ path_range_query::path_range_query (gimple_ranger &ranger,
}
path_range_query::path_range_query (gimple_ranger &ranger, bool resolve)
- : m_cache (new ssa_cache),
- m_has_cache_entry (BITMAP_ALLOC (NULL)),
+ : m_cache (),
m_ranger (ranger),
m_resolve (resolve)
{
@@ -62,8 +60,6 @@ path_range_query::path_range_query (gimple_ranger &ranger, bool resolve)
path_range_query::~path_range_query ()
{
delete m_oracle;
- BITMAP_FREE (m_has_cache_entry);
- delete m_cache;
}
// Return TRUE if NAME is an exit dependency for the path.
@@ -75,15 +71,6 @@ path_range_query::exit_dependency_p (tree name)
&& bitmap_bit_p (m_exit_dependencies, SSA_NAME_VERSION (name)));
}
-// Mark cache entry for NAME as unused.
-
-void
-path_range_query::clear_cache (tree name)
-{
- unsigned v = SSA_NAME_VERSION (name);
- bitmap_clear_bit (m_has_cache_entry, v);
-}
-
// If NAME has a cache entry, return it in R, and return TRUE.
inline bool
@@ -92,21 +79,7 @@ path_range_query::get_cache (vrange &r, tree name)
if (!gimple_range_ssa_p (name))
return get_global_range_query ()->range_of_expr (r, name);
- unsigned v = SSA_NAME_VERSION (name);
- if (bitmap_bit_p (m_has_cache_entry, v))
- return m_cache->get_range (r, name);
-
- return false;
-}
-
-// Set the cache entry for NAME to R.
-
-void
-path_range_query::set_cache (const vrange &r, tree name)
-{
- unsigned v = SSA_NAME_VERSION (name);
- bitmap_set_bit (m_has_cache_entry, v);
- m_cache->set_range (name, r);
+ return m_cache.get_range (r, name);
}
void
@@ -130,7 +103,7 @@ path_range_query::dump (FILE *dump_file)
fprintf (dump_file, "\n");
}
- m_cache->dump (dump_file);
+ m_cache.dump (dump_file);
}
void
@@ -174,7 +147,7 @@ path_range_query::internal_range_of_expr (vrange &r, tree name, gimple *stmt)
if (m_resolve && defined_outside_path (name))
{
range_on_path_entry (r, name);
- set_cache (r, name);
+ m_cache.set_range (name, r);
return true;
}
@@ -188,7 +161,7 @@ path_range_query::internal_range_of_expr (vrange &r, tree name, gimple *stmt)
r.intersect (glob);
}
- set_cache (r, name);
+ m_cache.set_range (name, r);
return true;
}
@@ -225,7 +198,7 @@ path_range_query::reset_path (const vec<basic_block> &path,
m_path = path.copy ();
m_pos = m_path.length () - 1;
m_undefined_path = false;
- bitmap_clear (m_has_cache_entry);
+ m_cache.clear ();
compute_ranges (dependencies);
}
@@ -255,7 +228,7 @@ path_range_query::ssa_range_in_phi (vrange &r, gphi *phi)
if (m_resolve && m_ranger.range_of_expr (r, name, phi))
return;
- // Try to fold the phi exclusively with global or cached values.
+ // Try to fold the phi exclusively with global values.
// This will get things like PHI <5(99), 6(88)>. We do this by
// calling range_of_expr with no context.
unsigned nargs = gimple_phi_num_args (phi);
@@ -264,7 +237,7 @@ path_range_query::ssa_range_in_phi (vrange &r, gphi *phi)
for (size_t i = 0; i < nargs; ++i)
{
tree arg = gimple_phi_arg_def (phi, i);
- if (range_of_expr (arg_range, arg, /*stmt=*/NULL))
+ if (m_ranger.range_of_expr (arg_range, arg, /*stmt=*/NULL))
r.union_ (arg_range);
else
{
@@ -348,8 +321,6 @@ path_range_query::range_defined_in_block (vrange &r, tree name, basic_block bb)
void
path_range_query::compute_ranges_in_phis (basic_block bb)
{
- auto_bitmap phi_set;
-
// PHIs must be resolved simultaneously on entry to the block
// because any dependencies must be satisfied with values on entry.
// Thus, we calculate all PHIs first, and then update the cache at
@@ -365,16 +336,8 @@ path_range_query::compute_ranges_in_phis (basic_block bb)
Value_Range r (TREE_TYPE (name));
if (range_defined_in_block (r, name, bb))
- {
- unsigned v = SSA_NAME_VERSION (name);
- set_cache (r, name);
- bitmap_set_bit (phi_set, v);
- // Pretend we don't have a cache entry for this name until
- // we're done with all PHIs.
- bitmap_clear_bit (m_has_cache_entry, v);
- }
+ m_cache.set_range (name, r);
}
- bitmap_ior_into (m_has_cache_entry, phi_set);
}
// Return TRUE if relations may be invalidated after crossing edge E.
@@ -408,7 +371,7 @@ path_range_query::compute_ranges_in_block (basic_block bb)
{
tree name = ssa_name (i);
if (ssa_defined_in_bb (name, bb))
- clear_cache (name);
+ m_cache.clear_range (name);
}
// Solve dependencies defined in this block, starting with the PHIs...
@@ -421,7 +384,7 @@ path_range_query::compute_ranges_in_block (basic_block bb)
if (gimple_code (SSA_NAME_DEF_STMT (name)) != GIMPLE_PHI
&& range_defined_in_block (r, name, bb))
- set_cache (r, name);
+ m_cache.set_range (name, r);
}
if (at_exit ())
@@ -457,7 +420,7 @@ path_range_query::compute_ranges_in_block (basic_block bb)
if (get_cache (cached_range, name))
r.intersect (cached_range);
- set_cache (r, name);
+ m_cache.set_range (name, r);
if (DEBUG_SOLVER)
{
fprintf (dump_file, "outgoing_edge_range_p for ");
@@ -500,7 +463,7 @@ path_range_query::adjust_for_non_null_uses (basic_block bb)
r.set_varying (TREE_TYPE (name));
if (m_ranger.m_cache.m_exit.maybe_adjust_range (r, name, bb))
- set_cache (r, name);
+ m_cache.set_range (name, r);
}
}