diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2023-03-28 11:35:26 -0400 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2023-04-26 15:17:08 -0400 |
commit | 0a38f677463ff8a4fb61b049263aa596ef6471a7 (patch) | |
tree | 28f6ae3086f4e023f3ea48f49e4086776e4995ef /gcc/gimple-range-cache.h | |
parent | 8a3590e5ce8fcc6b381d9572edbca6157bd67cfd (diff) | |
download | gcc-0a38f677463ff8a4fb61b049263aa596ef6471a7.zip gcc-0a38f677463ff8a4fb61b049263aa596ef6471a7.tar.gz gcc-0a38f677463ff8a4fb61b049263aa596ef6471a7.tar.bz2 |
Create a lazy ssa_cache.
Sparsely used ssa caches can benefit from using a bitmap to
determine if a name already has an entry. Utilize it in the path query
and remove its private bitmap for tracking the same info.
Also use it in the "assume" query class.
PR tree-optimization/108697
* gimple-range-cache.cc (ssa_global_cache::clear_range): Do
not clear the vector on an out of range query.
(ssa_cache::dump): Use dump_range_query instead of get_range.
(ssa_cache::dump_range_query): New.
(ssa_lazy_cache::dump_range_query): New.
(ssa_lazy_cache::set_range): New.
* gimple-range-cache.h (ssa_cache::dump_range_query): New.
(class ssa_lazy_cache): New.
(ssa_lazy_cache::ssa_lazy_cache): New.
(ssa_lazy_cache::~ssa_lazy_cache): New.
(ssa_lazy_cache::get_range): New.
(ssa_lazy_cache::clear_range): New.
(ssa_lazy_cache::clear): New.
(ssa_lazy_cache::dump): New.
* gimple-range-path.cc (path_range_query::path_range_query): Do
not allocate a ssa_cache object nor has_cache bitmap.
(path_range_query::~path_range_query): Do not free objects.
(path_range_query::clear_cache): Remove.
(path_range_query::get_cache): Adjust.
(path_range_query::set_cache): Remove.
(path_range_query::dump): Don't call through a pointer.
(path_range_query::internal_range_of_expr): Set cache directly.
(path_range_query::reset_path): Clear cache directly.
(path_range_query::ssa_range_in_phi): Fold with globals only.
(path_range_query::compute_ranges_in_phis): Simply set range.
(path_range_query::compute_ranges_in_block): Call cache directly.
* gimple-range-path.h (class path_range_query): Replace bitmap
and cache pointer with lazy cache object.
* gimple-range.h (class assume_query): Use ssa_lazy_cache.
Diffstat (limited to 'gcc/gimple-range-cache.h')
-rw-r--r-- | gcc/gimple-range-cache.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h index 2d41f0c..9032df9 100644 --- a/gcc/gimple-range-cache.h +++ b/gcc/gimple-range-cache.h @@ -63,11 +63,44 @@ public: void clear_range (tree name); void clear (); void dump (FILE *f = stderr); -private: +protected: + virtual bool dump_range_query (vrange &r, tree name) const; vec<vrange *> m_tab; vrange_allocator *m_range_allocator; }; +// This is the same as global cache, except it maintains an active bitmap +// rather than depending on a zero'd out vector of pointers. This is better +// for sparsely/lightly used caches. +// It could be made a fully derived class, but at this point there doesnt seem +// to be a need to take the performance hit for it. + +class ssa_lazy_cache : protected ssa_cache +{ +public: + inline ssa_lazy_cache () { active_p = BITMAP_ALLOC (NULL); } + inline ~ssa_lazy_cache () { BITMAP_FREE (active_p); } + bool set_range (tree name, const vrange &r); + inline bool get_range (vrange &r, tree name) const; + inline void clear_range (tree name) + { bitmap_clear_bit (active_p, SSA_NAME_VERSION (name)); } ; + inline void clear () { bitmap_clear (active_p); } + inline void dump (FILE *f = stderr) { ssa_cache::dump (f); } +protected: + virtual bool dump_range_query (vrange &r, tree name) const; + bitmap active_p; +}; + +// Return TRUE if NAME has a range, and return it in R. + +bool +ssa_lazy_cache::get_range (vrange &r, tree name) const +{ + if (!bitmap_bit_p (active_p, SSA_NAME_VERSION (name))) + return false; + return ssa_cache::get_range (r, name); +} + // This class provides all the caches a global ranger may need, and makes // them available for gori-computes to query so outgoing edges can be // properly calculated. |