xtensa: Optimize stack frame adjustment more
authorTakayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
Sat, 7 Jan 2023 02:55:11 +0000 (11:55 +0900)
committerMax Filippov <jcmvbkbc@gmail.com>
Sat, 7 Jan 2023 20:21:55 +0000 (12:21 -0800)
commitb095a1db483c1a9522a768e52743440d6987c2cd
tree7a9a26ee432c3cd090e2ed6ada0750761313209c
parent2d2edf108026b7e2591900f995bc558ce8d45c6d
xtensa: Optimize stack frame adjustment more

This patch introduces a convenient helper function for integer immediate
addition with scratch register as needed, that splits and emits either
up to two ADDI/ADDMI machine instructions or an addition by register
following an integer immediate load (which may later be transformed by
constantsynth).

By using the helper function, it makes stack frame adjustment logic
simplified and instruction count less in some cases.

gcc/ChangeLog:

* config/xtensa/xtensa.cc
(xtensa_split_imm_two_addends, xtensa_emit_add_imm):
New helper functions.
(xtensa_set_return_address, xtensa_output_mi_thunk):
Change to use the helper function.
(xtensa_emit_adjust_stack_ptr): Ditto.
And also change to try reusing the content of scratch register
A9 if the register is not modified in the function body.
gcc/config/xtensa/xtensa.cc