Prepare value-range analysis to handle multiple sub-ranges.
Value-range analysis data structure refactored to support multiple sub-ranges per slot.
The internal data structure for value-range analysis has been refactored to prepare for supporting multiple sub-ranges efficiently. The current implementation, limited to one sub-range per slot, now stores endpoints in a one-element array. This change modifies various functions to iterate over a new m_num_ranges field and adds guards for single-range operations, laying the groundwork for future enhancements.
In Details
The frange and frange_storage classes in value-range.cc have been modified to accommodate future support for multiple disjoint value ranges per analyzed variable. The existing m_min and m_max members, representing a single contiguous range, are replaced by an array of pairs (m_pairs) and a count (m_num_ranges). Consumers of the frange class that iterated over sub-ranges have been updated to loop m_num_ranges times. Single-range specific functions now include a m_num_ranges == 1 guard.
- value-range analysis
- A compiler optimization technique that determines the possible range of values a variable can hold at different points in the program. This information can be used to perform optimizations like constant folding or dead code elimination.
- sub-range
- A contiguous portion of the possible values a variable can take. In value-range analysis, a variable might be known to fall within multiple disjoint sub-ranges.