Rewrite union to merge sub-ranges.
frange::union_ operation now correctly merges sub-ranges instead of widening to the hull.
The frange::union_ operation has been rewritten to correctly handle and merge sub-ranges. Previously, it would widen the result to the outer bounds (hull) of the combined ranges, losing precision. The new implementation merges the sub-ranges of both operands, resulting in a more accurate representation of the union, although currently, due to MAX_PAIRS still being one, the result is collapsed back to a single range by set_pairs. This change is a preparatory step for future enhancements.
In Details
The frange::union_ method was refactored to use set_pairs to merge sub-ranges from both operands, rather than computing the convex hull. Currently, MAX_PAIRS = 1, so set_pairs collapses the result. This is a precursor to raising MAX_PAIRS.
- frange::union_
- A method within GCC for calculating the union of two value range sets, potentially comprising multiple sub-ranges.
- sub-ranges
- Distinct, contiguous portions of a larger value range, used to represent more precise information about a variable's possible values.
- hull
- The smallest convex set containing a given set of points. In this context, it refers to the minimal encompassing range that covers all sub-ranges.
- set_pairs
- A function that sets or updates the sub-ranges within a frange object, potentially merging or normalizing them.
- MAX_PAIRS
- A compile-time constant defining the maximum number of sub-ranges that can be stored in a frange object.