https://gcc.gnu.org/g:05a64cd677c9fd2460fc675284275848a7c5a356

commit 05a64cd677c9fd2460fc675284275848a7c5a356
Author: Alexandre Oliva <[email protected]>
Date:   Wed Sep 10 19:59:20 2025 -0300

    [ira] avoid resetting ira_reg_equiv for function invariants
    
    An aarch64 toolchain built with --enable-default-pie fails
    gcc.target/aarch64/sme/nonlocal_goto_[123].c because the register
    allocator ends up resetting equivalences, so it concludes it needs to
    preserve a rematerializable function invariant across a call instead
    of rematerializing it.
    
    Allow function invariant equivalences to remain when the other
    circumstances that may require their removal don't apply.
    
    
    for  gcc/ChangeLog
    
            * ira.cc (setup_reg_equiv): Retain function invariant
            equivalences.

Diff:
---
 gcc/ira.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/ira.cc b/gcc/ira.cc
index 4eebc9c4c50f..4b71f04f80a0 100644
--- a/gcc/ira.cc
+++ b/gcc/ira.cc
@@ -4233,12 +4233,12 @@ setup_reg_equiv (void)
                            && REGNO (SET_SRC (set)) == (unsigned int) i);
                x = SET_DEST (set);
              }
-           if (! function_invariant_p (x)
+           if (! CONSTANT_P (x)
                || ! flag_pic
                /* A function invariant is often CONSTANT_P but may
                   include a register.  We promise to only pass
                   CONSTANT_P objects to LEGITIMATE_PIC_OPERAND_P.  */
-               || (CONSTANT_P (x) && LEGITIMATE_PIC_OPERAND_P (x)))
+               || LEGITIMATE_PIC_OPERAND_P (x))
              {
                /* It can happen that a REG_EQUIV note contains a MEM
                   that is not a legitimate memory operand.  As later

Reply via email to