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

--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>:

https://gcc.gnu.org/g:08af16bfea689d095f0d41ccfeed204178e6f8b6

commit r16-243-g08af16bfea689d095f0d41ccfeed204178e6f8b6
Author: Andrew Pinski <quic_apin...@quicinc.com>
Date:   Sat Apr 19 16:41:32 2025 -0700

    tailcall: Support ERF_RETURNS_ARG for tailcall [PR67797]

    r15-6943-g9c4397cafc5ded added support to undo IPA-VRP return value
optimization for tail calls,
    using the same code ERF_RETURNS_ARG can be supported for functions which
return one of their arguments.
    This allows for tail calling of memset/memcpy in some cases which were not
handled before.

    Note this is very similar to
https://gcc.gnu.org/legacy-ml/gcc-patches/2016-11/msg02485.html except
    it has a few more checks.  Also on the question of expand vs tail call here
is that this path is also
    used by the IPA-VRP return value path and yes we get a tail call.
    Note in the review in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83142#c2
mentions about
    re-instantiate a LHS on the call & propagate to dominating uses. Even
though that can be done
    for the ERF_RETURNS_ARG case, it is not done for the IPA-VRP return value
case already so I don't think
    there is anything to be done there.

    Changes since v1:
    * v2: Add an useless_type_conversion_p check as suggested by Jakub
          and add a testcase for that.
    * v3: Fix the order of arguments to useless_type_conversion_p.

    Bootstrapped and tested on x86_64-linux-gnu.

            PR tree-optimization/67797

    gcc/ChangeLog:

            * tree-tailcall.cc (find_tail_calls): Add support for
ERF_RETURNS_ARG.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/tailcall-14.c: New test.
            * gcc.dg/tree-ssa/tailcall-15.c: New test.

    Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>

Reply via email to