https://gcc.gnu.org/g:cfe20dd118f5b83cb5dfac890e02b5b0a169abc1

commit r17-4267-gcfe20dd118f5b83cb5dfac890e02b5b0a169abc1
Author: Takayuki 'January June' Suwa <[email protected]>
Date:   Sun Sep 13 05:00:33 2026 +0900

    xtensa: Exclude A0 register from RL_REGS regclass when TARGET_WINDOWED_ABI
    
    When the "Windowed Register Option" is configured in the Xtensa ISA,
    register A0 is reserved for the return address and cannot be used for
    other purposes.  Therefore, the A0 register should be excluded from
    the "preferred reload register" set, ie., the RL_REGS regclass.
    
    gcc/ChangeLog:
    
            * config/xtensa/xtensa.cc (xtensa_conditional_register_usage):
            Clear the bit corresponding to the A0 register from the
            HARD_REG_SET associated with RL_REGS, if TARGET_WINDOWED_ABI
            is enabled.

Diff:
---
 gcc/config/xtensa/xtensa.cc | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc
index f4b1151d2e0e..b1daa0f0a998 100644
--- a/gcc/config/xtensa/xtensa.cc
+++ b/gcc/config/xtensa/xtensa.cc
@@ -5379,16 +5379,20 @@ xtensa_conditional_register_usage (void)
        call_used_regs[i] = !!(call_used_regs[i] & c_mask);
     }
 
-  /* Remove hard FP register from the preferred reload registers set.  */
-  CLEAR_HARD_REG_BIT (reg_class_contents[(int)RL_REGS],
+  /* Remove hard frame pointer from the preferred reload registers set.  */
+  CLEAR_HARD_REG_BIT (reg_class_contents[RL_REGS],
                      HARD_FRAME_POINTER_REGNUM);
 
-  /* Register A0 holds the return address upon entry to a function
-     for the CALL0 ABI, but unlike the windowed register ABI, it is
-     not reserved for this purpose and may hold other values after
-     the return address has been saved.  */
+  /* Register A0 holds the return address upon entry to a function for
+     the CALL0 ABI, but unlike the windowed register ABI, it is not
+     reserved for this purpose and may hold other values after the return
+     address has been saved.  In a similar vein, register A0 should be
+     excluded from the preferred reload registers set when the windowed
+     register ABI is in effect.  */
   if (!TARGET_WINDOWED_ABI)
     fixed_regs[A0_REG] = 0;
+  else
+    CLEAR_HARD_REG_BIT (reg_class_contents[RL_REGS], A0_REG);
 }
 
 /* Map hard register number to register class */

Reply via email to