PhiProp now handles stores between loads and PHIs.
PhiProp pass can now propagate values through a store instruction between a load and the PHI node, improving optimization for certain C++ code patterns.
The PhiProp optimization pass now allows for one store instruction between a load and the phi node, enabling propagation in cases where a store instruction previously blocked the optimization. This change improves optimization for C++ code with min/max patterns where argument evaluation order affects optimization opportunities. Additional testcases were added to cover scenarios where the load would make a different.
In Details
PhiProp (phi propagation) is a tree-ssa pass that propagates values through PHI nodes. This commit modifies tree-ssa-phiprop.cc to allow for a single non-modifying store instruction between a load and the PHI node being used for insertion. This is handled in the can_handle_load function. The change addresses PR123120 and PR116823. The commit introduces an other_vuse argument to phiprop_insert_phi and updates the call to can_handle_load in propagate_with_phi.
For Context
Compilers use optimization passes to improve the generated code. Phi propagation is one such pass, focusing on how values flow through 'phi nodes,' which are used to merge values from different execution paths in the code. This commit enhances phi propagation by allowing it to work even when a store instruction is present between a load and a merging point. This improvement allows for better optimization of specific C++ code patterns, leading to potentially faster and more efficient programs.