]> git.ipfire.org Git - thirdparty/gcc.git/commit
xtensa: Define HONOR_REG_ALLOC_ORDER as 1
authorTakayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
Fri, 8 May 2026 21:04:48 +0000 (06:04 +0900)
committerMax Filippov <jcmvbkbc@gmail.com>
Mon, 11 May 2026 15:17:05 +0000 (08:17 -0700)
commitbb0cbdac196986de933f4f93097de021c3686d7c
tree2df94fc108b40272726f637f7067add0195246a7
parente7dcba03064011c65f3a87c1e89bdd281909b279
xtensa: Define HONOR_REG_ALLOC_ORDER as 1

Since the commit of the preceding patch for IRA, "ira: Scale save/restore
costs of callee save registers with block frequency" (3b9b8d6cfdf59337f4b7ce10ce92a98044b2657b),
the Xtensa ISA has shown a tendency to allocate slightly more function stack
frames, especially when using the CALL0 ABI.

     /* example */
     extern void foo(void);
     int test(int a) {
       int array[252];
       foo();
       asm volatile (""::"m"(array));
       return a;
     }

     ;; before (-O2 -mabi=call0)
     test:
      addi sp, sp, -16
      s32i.n a0, sp, 12
      addmi sp, sp, -0x400
      s32i a2, sp, 1008
      call0 foo
      l32i a2, sp, 1008
      addmi sp, sp, 0x400
      l32i.n a0, sp, 12
      addi sp, sp, 16
      ret.n

This patch disables the incorrect register save cost estimation in function
prologues/epilogues by defining the HONOR_REG_ALLOC_ORDER macro as 1.

     ;; after (-O2 -mabi=call0)
     test:
      addmi sp, sp, -0x400
      s32i a0, sp, 1020
      s32i a2, sp, 1016
      call0 foo
      l32i a2, sp, 1016
      l32i a0, sp, 1020
      addmi sp, sp, 0x400
      ret.n

gcc/ChangeLog:

* config/xtensa/xtensa.h (HONOR_REG_ALLOC_ORDER):
New macro definition.

gcc/testsuite/ChangeLog:

* gcc.target/xtensa/elim_callee_saved.c:
Revise the test item for the number of mov instructions in the
assembler output.
gcc/config/xtensa/xtensa.h
gcc/testsuite/gcc.target/xtensa/elim_callee_saved.c