On 6/22/2026 10:35 PM, Andrew Pinski wrote:
This adds a reduced cs-elim functionality which will be used
from phiopt. The design is similar to cond_store_replacement except
we are looking for a similar store right beore the condition.
This allows for 2 things, the reuse of the same aliasing set and
second is allows for use in phiopt in a secondary patch.

This can and will be expanded to support the case where there is a
similar load as the store before the condition for the cases that
is allowed, e.g. local non-addressable variables or decls when allowing
race conditions.

Note pr99473-1.c of a case where can be optimized even without
-fallow-store-data-races now. The store happens before the conditional
and inside the conditional, so afterwards there is only one store rather
than 2. The code was also handling it in sink in GCC 12 the same way too
but now handling it in cselim before sink1.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

        * tree-ssa-phiopt.cc (cond_store_replacement_limited): New function.
        (pass_cselim::execute): Call cond_store_replacement_limited before
        cond_store_replacement.

gcc/testsuite/ChangeLog:

        * gcc.dg/tree-ssa/pr99473-1.c: Remove -fallow-store-data-races as it is 
not
        needed with cond_store_replacement_limited.
Do you expect this work to ultimately provide meaningful infrastructure to help store elimination in cases like Daniel was looking at earlier (the bitmap_set_bit/bitmap_clear_bit stuff from spec2017)?  I'm trying to get my plate cleared so that I can help Daniel move that stuff forward as it represents the largest source of branch mispredicts we're seeing in 502.gcc.

At a high level, if we can get the same overall benefit from cs-elim by revamping a bit of how phi-opt works, then I'm generally in favor.

Jeff

Reply via email to