]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR123223, LRA]: Fix ICE of GCC built with checking rtl
authorVladimir N. Makarov <vmakarov@redhat.com>
Fri, 19 Dec 2025 18:22:49 +0000 (13:22 -0500)
committerVladimir N. Makarov <vmakarov@redhat.com>
Fri, 19 Dec 2025 18:22:49 +0000 (13:22 -0500)
The latest PR55212 patch improving dealing with scratch pseudos does not
check reload rtx on reg when recognizing scratch pseudos.  This
results in failure of GCC built with checking rtl.

gcc/ChangeLog:

PR rtl-optimization/123223
* lra-constraints.cc (match_reload, curr_insn_transform): Check
rtx on REG when testing scratch pseudos.

gcc/lra-constraints.cc

index 910f3fba8f4785587ec425d8ed86843dbff2e1a6..18b2c50e1e4abb427d73799edf7674549124667f 100644 (file)
@@ -1243,11 +1243,10 @@ match_reload (signed char out, signed char *ins, signed char *outs,
     return;
   /* See a comment for the input operand above.  */
   narrow_reload_pseudo_class (out_rtx, goal_class);
-  if (find_reg_note (curr_insn, REG_UNUSED, out_rtx) == NULL_RTX
-      && !ira_former_scratch_p (REGNO (SUBREG_P (out_rtx)
-                                      ? SUBREG_REG (out_rtx) : out_rtx)))
+  reg = SUBREG_P (out_rtx) ? SUBREG_REG (out_rtx) : out_rtx;
+  if (find_reg_note (curr_insn, REG_UNUSED, reg) == NULL_RTX
+      && (!REG_P (reg) || !ira_former_scratch_p (REGNO (reg))))
     {
-      reg = SUBREG_P (out_rtx) ? SUBREG_REG (out_rtx) : out_rtx;
       start_sequence ();
       /* If we had strict_low_part, use it also in reload to keep other
         parts unchanged but do it only for regs as strict_low_part
@@ -4861,7 +4860,7 @@ curr_insn_transform (bool check_only_p)
              && find_reg_note (curr_insn, REG_UNUSED, old) == NULL_RTX
              /* OLD can be an equivalent constant here.  */
              && !CONSTANT_P (old)
-             && !ira_former_scratch_p (REGNO (old)))
+             && (!REG_P(old) || !ira_former_scratch_p (REGNO (old))))
            {
              start_sequence ();
              lra_emit_move (type == OP_INOUT ? copy_rtx (old) : old, new_reg);