ranger: Use index range for loads from constant aggregates
Improves constant aggregate load optimization by using known index ranges.
The GCC compiler now optimizes loads from constant aggregates more effectively by considering the known range of the index. Instead of assuming the entire aggregate might be accessed, it now narrows the loaded values to only those elements that could possibly be reached by the index’s known range. This enables further optimizations, such as folding comparisons involving these narrowed loads.
In Details
This commit enhances the gimple-range-fold pass by allowing it to narrow loads from constant aggregates based on the known range of the array index. Previously, loads from constant tables always considered the entire table's data. Now, if the index SSA_NAME has a known range, the pass restricts the loaded values to only those elements within that range. This improvement, motivated by DOM parity and going beyond it, allows for more aggressive constant folding, particularly for comparisons involving such loads, and removes the need for special handling of INTEGER_CSTs.
- constant aggregate
- A data structure, such as an array or struct, whose elements are all constants known at compile time.
- range
- In the context of static analysis, the set of possible values a variable can hold. For example, an index might be known to be in the range [0, 10].
- load
- An operation that retrieves data from memory into a CPU register.
- SSA_NAME
- Static Single Assignment form, an intermediate representation where each variable is assigned exactly once. SSA_NAME refers to a variable in this form.
- constant folding
- An optimization technique where expressions with constant operands are evaluated at compile time rather than runtime.
- DOM parity
- Likely refers to achieving a similar level of optimization or analysis capability as another part of the compiler, possibly related to 'Dominator Tree' analysis, though the exact context here is specific to the author's goals.