]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
xtensa: Small changes to 'return' insn pattern
authorTakayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
Mon, 5 Jan 2026 18:59:35 +0000 (03:59 +0900)
committerMax Filippov <jcmvbkbc@gmail.com>
Tue, 6 Jan 2026 18:31:39 +0000 (10:31 -0800)
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))'.

gcc/config/xtensa/xtensa.h
gcc/config/xtensa/xtensa.md

index 84dc81457ae8b67cfba85dccff65a622b8db88ac..bdedf0ea9d806d4a45ad5a16da4d16b803e56db7 100644 (file)
@@ -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 ? \
index b095b8152ad40e757d04a58bd88ab5ad54728e7a..1e52bba1a465915f6665059eba18f5f7e478e500 100644 (file)
    (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") :
   "!TARGET_WINDOWED_ABI"
 {
   xtensa_expand_epilogue ();
-  emit_use (gen_rtx_REG (SImode, A0_REG));
   DONE;
 })