SSA Range Cache

The ssa_cache class provides a general-purpose table to store and query ranges associated with SSA names. It implements the range_query interface and is suitable for use anywhere in the compiler that needs a table of value ranges indexed by SSA names.

Basic Usage

To use an ssa_cache, create an instance and populate it as ranges become known. The following API methods are available:

All stored ranges are internally managed using a vrange_allocator, ensuring efficient memory reuse across queries.

Lazy Variant

The ssa_lazy_cache class inherits from ssa_cache and introduces sparse storage via an additional bitmap. It avoids zeroing the vector memory across all SSA names, and instead tracks active ssa-names via the bitmap.

This is particularly useful in situations when

The API is the same, but it provides an extra entry point:

Integration with `range_query`

Both ssa_cache and ssa_lazy_cache inherit from the range_query interface. This allows them to be passed to any part of the compiler infrastructure that expects a range_query—for example, routines that perform range-based folding or simplification.

By implementing range_of_expr(), the cache can be queried as a first-class source of value ranges for SSA names, making it easy to plug into expression evaluators or propagation engines without needing custom glue code.

Summary

Feature

ssa_cache

ssa_lazy_cache

Storage

Dense (vector)

Sparse (bitmap + vector)

Setup cost

Higher upfront

Lower for sparse use

clear() cost

High (full scan)

Low (bitmap-driven)

Best for

Most SSA names used

Few SSA names used

Memory usage

Higher

Lower in sparse cases

Both classes provide consistent, fast range lookup and modification, and integrate smoothly with the broader Ranger infrastructure via the range_query interface.

None: SsaCacheDetails (last edited 2025-04-02 15:51:33 by AndrewMacLeod)