FRE optimization improved by fixing aliasing walk logic
Fixes a bug in alias analysis that caused incorrect handling of PHI nodes, enabling more effective loop-invariant code motion.
This commit addresses an issue in GCC’s alias analysis that prevented loop-invariant code motion (LICM) from being applied effectively in certain loop scenarios. The problem occurred when translating aliased uses, causing the get_continuation_for_phi function to fail. By clearing the visited bitmap during translation and removing an unnecessary abort_on_visited flag, the analysis can now correctly traverse complex control flow, enabling more FRE optimizations.
In Details
The tree-ssa-alias.cc and tree-ssa-alias.h files implement alias analysis. The get_continuation_for_phi function, used by FRE, previously aborted if it encountered an already visited region when abort_on_visited was true, even if the current reference translation was different. This commit changes walk_non_aliased_vuses to clear the visited bitmap upon reference translation instead of tracking it, thus removing the need for abort_on_visited. This resolves PR127693 by ensuring all regions are verified with the current reference, allowing FRE to succeed in loops where control flow m…
- FRE
- Frequently Re-computed Expression, an optimization pass that identifies and hoists expressions computed multiple times within a loop to be computed only once outside the loop.
- Loop-invariant code motion (LICM)
- An optimization that moves computations from inside a loop to the outside if their results do not change between loop iterations.
- PHI node
- In SSA form, a special node that represents the merging of values from different control flow paths. It takes multiple arguments, each corresponding to a predecessor block.
- Alias analysis
- Compiler analysis that determines whether different memory references (pointers or array accesses) might refer to the same memory location.
- tree-ssa-alias.cc
- The GCC source file implementing alias analysis on the SSA intermediate representation.
- get_continuation_for_phi
- A function within GCC's alias analysis that determines the correct value for a variable at a PHI node, considering potential aliasing.