https://gcc.gnu.org/g:384c6aef8b5d0378444ea23ea4b85556ed524986

commit r16-6524-g384c6aef8b5d0378444ea23ea4b85556ed524986
Author: Takayuki 'January June' Suwa <[email protected]>
Date:   Tue Jan 6 03:59:35 2026 +0900

    xtensa: Small changes to 'return' insn pattern
    
    This pattern is only emitted during function epilogue expansion (obviously
    after register allocation), so putting reload_completed in the condition
    is redundant.
    
    This patch also changes the declaration of the return register (A0 address
    register) required for normal function returns to properly defining the
    EPILOGUE_USES macro, as is already done on other targets, rather than
    placing '(use (reg:SI A0_REG))' RTX.
    
    gcc/ChangeLog:
    
            * config/xtensa/xtensa.h (EPILOGUE_USES): New macro definition.
            * config/xtensa/xtensa.md (return):
            Remove '(use (reg:SI A0_REG))' from the template description, and
            reload_completed from the condition.
            (sibcall_epilogue): Remove emitting '(use (reg:SI A0_REG))'.

Diff:
---
 gcc/config/xtensa/xtensa.h  |  4 ++++
 gcc/config/xtensa/xtensa.md | 11 ++++-------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
index 84dc81457ae8..bdedf0ea9d80 100644
--- a/gcc/config/xtensa/xtensa.h
+++ b/gcc/config/xtensa/xtensa.h
@@ -522,6 +522,10 @@ typedef struct xtensa_args
 /* Stack pointer value doesn't matter at exit.  */
 #define EXIT_IGNORE_STACK 1
 
+/* The "return" pattern requires A0 register as return address, and is
+   also required so that restoring A0 in the epilogue is not dead code.  */
+#define EPILOGUE_USES(REGNO) ((REGNO) == A0_REG)
+
 /* Size in bytes of the trampoline, as an integer.  Make sure this is
    a multiple of TRAMPOLINE_ALIGNMENT to avoid -Wpadded warnings.  */
 #define TRAMPOLINE_SIZE (TARGET_WINDOWED_ABI ? \
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index b095b8152ad4..1e52bba1a465 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -2616,12 +2616,10 @@
    (set_attr "length"  "3")])
 
 (define_insn "return"
-  [(return)
-   (use (reg:SI A0_REG))]
-  "reload_completed
-   && (TARGET_WINDOWED_ABI
-       || compute_frame_size (get_frame_size ()) == 0
-       || epilogue_completed)"
+  [(return)]
+  "TARGET_WINDOWED_ABI
+   || compute_frame_size (get_frame_size ()) == 0
+   || epilogue_completed"
 {
   return TARGET_WINDOWED_ABI ?
       (TARGET_DENSITY ? "retw.n" : "retw") :
@@ -2685,7 +2683,6 @@
   "!TARGET_WINDOWED_ABI"
 {
   xtensa_expand_epilogue ();
-  emit_use (gen_rtx_REG (SImode, A0_REG));
   DONE;
 })

Reply via email to