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))'.
This commit is contained in:
Takayuki 'January June' Suwa
2026-01-06 03:59:35 +09:00
committed by Max Filippov
parent 8b8d234304
commit 384c6aef8b
2 changed files with 8 additions and 7 deletions

View 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 ? \

View File

@@ -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;
})