ranger: give loads from constant tables of floats a range
Compiler now determines value ranges for loads from constant float arrays, improving optimization potential.
GCC’s ranger pass, responsible for determining value ranges, previously could not handle loads from constant arrays of floating-point numbers. While constant propagation (cprop) could optimize loads from double arrays, ranger lacked this capability. This commit extends ranger to correctly determine the range of values loaded from constant tables containing floats, enabling further optimizations that rely on value range information, especially in conditional code.
In Details
The gimple-range-fold.cc pass, specifically range_from_readonly_load and fold_using_range::range_from_readonly_var, previously had a TODO item preventing it from handling floating-point types in constant tables. This commit removes that limitation by allowing range_from_missing_constructor_part and fold_using_range::range_from_readonly_var to handle REAL_CST values. This enables ranger to compute value ranges for loads from constant arrays of floats, similar to how it handles integers, thereby improving optimizations like conditional folding.
- ranger
- A GCC pass that computes the possible range of values for program variables and expressions. This information is used by other optimization passes.
- constant propagation
- An optimization that replaces variables or expressions with their constant values during compilation. If a variable is assigned a constant and never changed, its value can be substituted directly.
- cprop
- Abbreviation for Constant Propagation, a compiler optimization pass.
- float
- A data type representing floating-point numbers, which have a fractional part and are typically stored in binary formats like IEEE 754.
- SSA
- Static Single Assignment form, an intermediate representation used by GCC where each variable is assigned exactly once, simplifying many analyses and optimizations.