The patch in the attachment is for

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

The patch was successfully bootstrapped and tested on x86-64, aarch64, an ppc64le.

commit 6bfe24239a2c98ecacfbda6358a46c41e40c18ac
Author: Vladimir N. Makarov <[email protected]>
Date:   Fri Mar 13 16:19:33 2026 -0400

    [PR117182, LRA]: Move point of skipping postponed insn
    
    Working on PR117182 I found that a pseudo generated for save/restore
    value around call is changed by equivalence which is constant as we
    propagate equivalence for such pseudos to generate a better code.  The
    constant substitutes output of the save insn which can be changed to
    memory containing constant by reload insn.  We don't want this.  The
    patch fixes this.
    
    gcc/ChangeLog:
    
            PR target/117182
            * lra-constraints.cc (curr_insn_transform): Don't change an output
            operand by constant or invariant equivalence.

diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc
index 485ffa98c40..77b221f136d 100644
--- a/gcc/lra-constraints.cc
+++ b/gcc/lra-constraints.cc
@@ -4419,7 +4419,12 @@ curr_insn_transform (bool check_only_p)
 	    && !targetm.hard_regno_mode_ok (REGNO (subst), outer_mode))
 	  continue;
 
-	if (subst != old)
+	if (subst != old
+	    /* We don't want to change an out operand by constant or invariant
+	       which will require additional reloads, e.g. by putting a constant
+	       into memory.  */
+	    && (curr_static_id->operand[i].type == OP_IN || MEM_P (subst)
+		|| (GET_CODE (subst) == SUBREG && MEM_P (SUBREG_REG (subst)))))
 	  {
 	    equiv_substition_p[i] = true;
 	    rtx new_subst = copy_rtx (subst);

Reply via email to