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

--- Comment #16 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Jakub Jelinek
<[email protected]>:

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

commit r15-11224-ge8891fe419a502cd5653840747101d1942b6fc92
Author: Jakub Jelinek <[email protected]>
Date:   Fri Apr 24 14:50:23 2026 +0200

    rs6000: Don't fold stuff for C++ during targetm.resolve_overloaded_builtin
[PR124133]

    The following testcase ICEs starting with the removal of NON_DEPENDENT_EXPR
    in GCC 14.  The problem is that while parsing templates if all the
arguments
    of the overloaded builtins are non-dependent types,
    targetm.resolve_overloaded_builtin can be called on it.  And trying to
    fold_convert or fold_build2 subexpressions of such arguments can ICE,
    because they can contain various FE specific trees, or standard trees
    with NULL_TREE types, or e.g. type mismatches in binary tree operands etc.
    All that goes away later when the trees are instantiated and
    targetm.resolve_overloaded_builtin is called again, but if it ICEs while
    doing that, it won't reach that point.  And the reason to call that
    hook in that case if none of the arguments are type dependent is to figure
    out if the result type is also non-dependent.

    Given the general desire to fold stuff in the FE during parsing as little
    as possible and fold it only during cp_fold later on and because from the
    target *-c.cc files it isn't easily possible to find out if it is
    processing_template_decl or not, the following patch just stops folding
    anything in the arguments, calls convert instead of fold_convert and
    just build2 instead of fold_build2 etc. when in C++ (and keeps doing what
    it did for C).

    2026-04-24  Jakub Jelinek  <[email protected]>

            PR target/124133
            * config/rs6000/rs6000-c.cc (c_fold_convert): New function.
            (c_fold_build2_loc): Likewise.
            (fully_fold_convert): Use c_fold_convert instead of fold_convert.
            (altivec_build_resolved_builtin): Likewise.  Use c_fold_build2_loc
            instead of fold_build2.
            (resolve_vec_mul, resolve_vec_adde_sube, resolve_vec_addec_subec):
            Use c_fold_build2_loc instead of fold_build2_loc.
            (resolve_vec_splats, resolve_vec_extract): Use c_fold_convert
instead
            of fold_convert.
            (resolve_vec_insert): Use c_fold_build2_loc instead of fold_build2.
            (altivec_resolve_overloaded_builtin): Use c_fold_convert instead
            of fold_convert.

            * g++.target/powerpc/pr124133-1.C: New test.
            * g++.target/powerpc/pr124133-2.C: New test.

    Reviewed-by: Michael Meissner <[email protected]>
    (cherry picked from commit d3c189cd8a9eecc2ae350351185d59d6f6eafe28)

Reply via email to