Improve IPA analysis of unknown-offset loads and PHI walking
GCC's interprocedural analysis now better handles loads with unknown offsets and deep PHI chains, improving optimization for inlined functions.
This set of commits significantly enhances GCC’s interprocedural analysis (IPA) for handling loads with unknown offsets, particularly when aggregate parameters are involved. It improves the analysis of comparisons and switches on such loads, extends PHI walking to correctly track values across inlined functions and loops, and raises the limit for IPA jump function lookups to better analyze complex pointer chains. These changes aim to improve optimization accuracy, especially for functions marked with always_inline.
In Details
Commits 9961d5f117c4afe323dc1be8b0df9031b28265e4, 173072492587491dea9e2b0a9d02da9e4dff2c65, and 7ce404d9c953b0a1b51e1501ca7332b037170481 enhance GCC's IPA subsystem by improving the analysis of aggregate loads with unknown offsets and extending PHI walking capabilities. 9961d5f117c4afe323dc1be8b0df9031b28265e4 extends will_be_nonconstant_predicate and phi_result_unknown_predicate to handle comparisons and switches on aggregate loads with unknown_offset or maybe_modified, and increases the ipa-jump-function-lookups limit. 173072492587491dea9e2b0a9d02da9e4dff2c65 adds PHI wa…
- Interprocedural Analysis (IPA)
- A compile-time analysis that examines relationships and dependencies between different functions within a program, rather than just a single function in isolation. It's used to enable optimizations that require knowledge beyond a single function's scope.
- PHI node
- A special node in Static Single Assignment (SSA) form, used to represent the assignment of a value when control flow paths merge. A PHI node selects one of several input values based on which predecessor block was executed.
- GIMPLE
- GCC's internal three-address code representation, used after parsing and initial transformations. It's designed to be simpler than the original source code and easier for optimization passes to manipulate.
- unknown_offset
- A state in GCC's analysis indicating that the precise memory offset being accessed within an aggregate data structure cannot be determined at compile time. This often occurs with pointer arithmetic or indirect accesses.
- STRING_CST
- An internal representation in GCC for a string constant.
- always_inline
- A function attribute that suggests to the compiler that the function should be inlined at every call site, even if the compiler might otherwise decide against it. This can improve performance by reducing function call overhead but can increase code size.