Rewrite intersect to meet sub-ranges pairwise.
frange::intersect operation now pairwise intersects sub-ranges for more precise results.
The frange::intersect operation has been rewritten to perform pairwise intersections of sub-ranges from two range sets. This provides a more accurate intersection result compared to the previous method, which treated the ranges as single intervals. As MAX_PAIRS is still 1, the cross-product in the intersection will yield at most one resulting piece, meaning no functional change for now, but this lays the groundwork for handling multiple sub-ranges more effectively in the future.
In Details
The frange::intersect method now performs pairwise intersection of sub-ranges, iterating through the cross product of sub-ranges from both operands. This replaces the prior single-interval intersection logic. Due to MAX_PAIRS still being 1, the result is effectively the same as before, but the infrastructure is in place for future enhancements.
- frange::intersect
- A method in GCC's value range analysis that computes the intersection of two sets of possible values for a variable.
- sub-ranges
- Distinct, contiguous portions of a larger value range, used to represent more precise information about a variable's possible values.
- pairwise intersection
- An operation where each sub-range from one set is intersected with each sub-range from another set.
- MAX_PAIRS
- A compile-time constant defining the maximum number of sub-ranges that can be stored in a frange object.
- frange_min
- A helper function to determine the minimum value of a frange, considering its sub-ranges.
- frange_max
- A helper function to determine the maximum value of a frange, considering its sub-ranges.