tree-optimization: Fix LIM dependence cache indexing
Corrected indexing for LIM dependence cache improves reuse of cached results.
This commit fixes an issue with the LIM (Loop Invariant Motion) dependence cache indexing within GCC’s tree optimization passes. By correctly parenthesizing the dependence-state comparison, the cache index now accurately includes the loop number and dependence kind. This allows for more effective reuse of cached dependence results, improving optimization efficiency.
In Details
In tree-ssa-loop-im.cc, the record_loop_dependence function's logic for computing the cache index was flawed. The dependence-state comparison was not properly parenthesized, leading to an incorrect index calculation that did not account for both the loop number and the dependence kind. This change corrects the expression to ensure the cache index accurately reflects these factors, enabling the reuse of previously computed dependence information for subsequent loop optimizations.
- tree-optimization
- A phase in GCC optimization that operates on an intermediate representation called GENERIC trees, which are higher-level than GIMPLE.
- LIM
- Loop Invariant Motion, an optimization technique that moves computations out of loops if their results do not change within the loop.
- dependence cache
- A data structure used by the compiler to store and quickly retrieve information about data dependencies between loop iterations or program statements.
- Loop Invariant Motion (LIM)
- An optimization technique that identifies computations within a loop whose results are constant across all iterations and moves them outside the loop.
- tree-ssa
- A GCC optimization framework that uses the SSA (Static Single Assignment) form on the GENERIC tree intermediate representation.