Fix store-merging to disregard TBAA when disambiguating against calls
Improves store-merging by correctly ignoring TBAA when disambiguating memory operations against function calls.
This commit corrects an issue in GCC’s store-merging optimization where the analysis failed to disregard Tree-based Alias Analysis (TBAA) information when disambiguating memory stores against function calls. This led to incorrect aliasing decisions. The fix modifies stmt_may_clobber_ref_p_1 to ensure that TBAA is not used in these specific disambiguation scenarios, particularly when sinking loads or stores across stores. This improves the accuracy of alias analysis and store-merging, potentially enabling more aggressive optimizations.
In Details
This patch addresses PR tree-optimization/128463 by refining how alias analysis interacts with store-merging, specifically concerning calls. The pass_store_merging::terminate_all_aliasing_chains and stmts_may_clobber_ref_p functions are simplified to ensure that TBAA information is not used when disambiguating whether a statement may clobber a reference against a function call. The rationale is that when sinking loads or stores across stores, TBAA should not be considered for this particular check, as it can lead to overly conservative aliasing assumptions and hinder store-merging.
- store-merging
- An optimization pass in GCC that attempts to combine multiple store operations to the same memory location into a single store, reducing memory traffic.
- TBAA (Tree-based Alias Analysis)
- A compiler technique that analyzes memory access patterns to determine if different memory references might point to the same location (aliasing). TBAA uses a tree-like structure to represent type information and resolve potential aliases.
- disambiguate
- To determine whether two memory accesses are guaranteed to refer to different memory locations.
- sinking loads or stores
- An optimization technique where memory read (load) or write (store) operations are moved to a later point in the program's execution, often across other operations, to enable other optimizations.
- gimple-ssa-store-merging.cc
- A GCC source file implementing the store-merging optimization pass within the GIMPLE SSA (Static Single Assignment) intermediate representation.