Convert operator_negate::fold_range to use sub-ranges
Improves range analysis for negation by preserving gaps between sub-ranges.
This change refactors operator_negate::fold_range to negate each sub-range individually before combining them. This prevents the loss of information about gaps between sub-ranges that previously occurred when the negation operation caused the overall range to collapse. The test suite is updated to verify this corrected behavior.
In Details
Refactors operator_negate::fold_range in range-op-float.cc to correctly handle multi-valued floating-point ranges. Similar to operator_abs, the previous implementation could collapse sub-ranges by taking the negation of the overall hull. The updated version negates each sub-range independently and then unions the results, preserving the structure of the original range's sub-intervals.
- range analysis
- A compiler optimization technique that determines the possible range of values a variable or expression can take. This information can enable further optimizations.
- sub-ranges
- In range analysis, a range may be composed of multiple disjoint intervals, especially when dealing with functions that are not monotonic (like absolute value or negation). These intervals are called sub-ranges.
- fold_range
- A function within the range analysis framework that computes the resulting range after applying a specific operation (e.g., absolute value, negation) to an input range.
- hull
- The smallest single interval that completely encloses all values of a given range or set of sub-ranges.