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

--- Comment #18 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <[email protected]>:

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

commit r16-3947-gd5e80bf7571836bb307f38e45f0e6ba392cdcc3d
Author: Richard Biener <[email protected]>
Date:   Thu Sep 18 10:41:45 2025 +0200

    tree-optimization/87615 - VN predication is expensive

    The following restricts the number of locations we register a predicate
    as valid which avoids the expensive linear search for cases like

       if (a)
         A;
       if (a)
         B;
       if (a)
         C;
       ...

    where we register a != 0 as true for locations A, B, C ... in an
    unlimited way.  The patch simply choses 8 as limit.  The underlying
    issue for this case is the data structure which does not allow for
    easy "forgetting" or more optimal searching when locations become
    no longer relevant (the whole point of the location list is to
    represent where predicates are relevant).

    The patch also splits the search/copy loop into two to avoid copying
    stuff that we'll not need when finding an existing better entry or,
    new now, when we figure we run over the limit.

            PR tree-optimization/87615
            * tree-ssa-sccvn.cc (vn_nary_op_insert_into): When inserting
            a new predicate or location into an existing predicate list
            make sure to not exceed 8 locations.  Avoid copying things
            when we later eventually throw them away.
            (vn_nary_op_insert_pieces_predicated): Avoid expensive check
            when not checking.
            (dominated_by_p_w_unex): Apply the limit on a single successors
            predecessor count consistently.

Reply via email to