https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106433

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:cad2412cc84518195fceb2db31e82e6df7e5a2c2

commit r13-5727-gcad2412cc84518195fceb2db31e82e6df7e5a2c2
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Tue Feb 7 10:33:54 2023 +0100

    cgraph: Handle simd clones in cgraph_node::set_{const,pure}_flag [PR106433]

    The following testcase ICEs, because we determine only in late pure const
    pass that bar is const (the content of the function loses a store to a
    global var during dse3 and read from it during cddce2) and
local-pure-const2
    makes it const.  The cgraph ordering is that post IPA (in late IPA simd
    clones are created) bar is processed first, then foo as its caller, then
    foo.simdclone* and finally bar.simdclone*.  Conceptually I think that is
the
    right ordering which allows for static simd clones to be removed.

    The reason for the ICE is that because bar was marked const, the call to
    it lost vops before vectorization, and when we in foo.simdclone* try to
    vectorize the call to bar, we replace it with bar.simdclone* which hasn't
    been marked const and so needs vops, which we don't add.

    Now, because the simd clones are created from the same IL, just in a loop
    with different argument/return value passing, I think generally if the base
    function is determined to be const or pure, the simd clones should be too,
    unless e.g. the vectorization causes different optimization decisions, but
    then still the global memory reads if any shouldn't affect what the
function
    does and global memory stores shouldn't be reachable at runtime.

    So, the following patch changes set_{const,pure}_flag to mark also simd
    clones.

    2023-02-07  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/106433
            * cgraph.cc (set_const_flag_1): Recurse on simd clones too.
            (cgraph_node::set_pure_flag): Call set_pure_flag_1 on simd clones
too.

            * gcc.c-torture/compile/pr106433.c: New test.

Reply via email to