On Dec 19, 2025, Vladimir Makarov <[email protected]> wrote:

> On 12/19/25 11:06 AM, Jakub Jelinek wrote:
>> On Fri, Dec 19, 2025 at 04:33:04PM +0100, Tobias Burnus wrote:
>>> Vladimir Makarov wrote:
>>>> So the patch has sense.  You can commit it into the trunk.  Thank you
>>>> for the patch, Alex.

>>> This patch unfortunately breaks GCN bootstrap,
>>> cf. https://gcc.gnu.org/PR123223

>> x86_64 and i686-linux bootstrap as well, all with
>> --enable-checking=yes,rtl,extra
>> REGNO is used multiple times in the patch without making sure
>> it is applied on REG_P only.

> Sorry for the troubles.  I'll fix it as soon as possible or revert
> Alex's patch if I can not do it today.

Ugh, sorry, it looks like this patch wasn't quite as baked as I believed :-(

The following patchlet should fix that.  I'm giving it a spin and then
I'll push it as obvious.

diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc
index 910f3fba8f478..6cf6e40a09a99 100644
--- a/gcc/lra-constraints.cc
+++ b/gcc/lra-constraints.cc
@@ -1244,8 +1244,10 @@ match_reload (signed char out, signed char *ins, signed 
char *outs,
   /* 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_P (out_rtx)
+           || (SUBREG_P (out_rtx) && REG_P (SUBREG_REG (out_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;
       start_sequence ();
@@ -4861,7 +4863,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);


-- 
Alexandre Oliva, happy hacker            https://blog.lx.oliva.nom.br/
Free Software Activist     FSFLA co-founder     GNU Toolchain Engineer
Learn the truth about Richard Stallman at https://stallmansupport.org/

Reply via email to