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

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Surya Kumari Jangala
<jskum...@gcc.gnu.org>:

https://gcc.gnu.org/g:3c67a0fa1dd39a3378deb854a7fef0ff7fe38004

commit r15-2810-g3c67a0fa1dd39a3378deb854a7fef0ff7fe38004
Author: Surya Kumari Jangala <jskum...@linux.ibm.com>
Date:   Thu Dec 7 22:42:43 2023 -0600

    lra: emit caller-save register spills before call insn [PR116028]

    LRA emits insns to save caller-save registers in the
    inheritance/splitting pass. In this pass, LRA builds EBBs (Extended
    Basic Block) and traverses the insns in the EBBs in reverse order from
    the last insn to the first insn. When LRA sees a write to a pseudo (that
    has been assigned a caller-save register), and there is a read following
    the write, with an intervening call insn between the write and read,
    then LRA generates a spill immediately after the write and a restore
    immediately before the read. The spill is needed because the call insn
    will clobber the caller-save register.

    If there is a write insn and a call insn in two separate BBs but
    belonging to the same EBB, the spill insn gets generated in the BB
    containing the write insn. If the write insn is in the entry BB, then
    the spill insn that is generated in the entry BB prevents shrink wrap
    from happening. This is because the spill insn references the stack
    pointer and hence the prolog gets generated in the entry BB itself.

    This patch ensures the the spill insn is generated before the call insn
    instead of after the write. This also ensures that the spill occurs
    only in the path containing the call.

    2024-08-01  Surya Kumari Jangala  <jskum...@linux.ibm.com>

    gcc:
            PR rtl-optimization/116028
            * lra-constraints.cc (split_reg): Spill register before call
            insn.
            (latest_call_insn): New variable.
            (inherit_in_ebb): Track the latest call insn.

    gcc/testsuite:
            PR rtl-optimization/116028
            * gcc.dg/ira-shrinkwrap-prep-1.c: Remove xfail for powerpc.
            * gcc.dg/pr10474.c: Remove xfail for powerpc.

Reply via email to