On Wed, Aug 20, 2025 at 4:30 AM Takayuki 'January June' Suwa <jjsuwa_sys3...@yahoo.co.jp> wrote: > > This patch changes the implementation of the insn to test whether the > result itself is negative or not, rather than the MSB of the result of > the ABS machine instruction. This eliminates the need to consider bit- > endianness and allows for longer branch distances. > > /* example */ > extern void foo(int); > void test0(int a) { > if (a == -2147483648) > foo(a); > } > void test1(int a) { > if (a != -2147483648) > foo(a); > } > > ;; before (endianness: little) > test0: > entry sp, 32 > abs a8, a2 > bbci a8, 31, .L1 > mov.n a10, a2 > call8 foo > .L1: > retw.n > test1: > entry sp, 32 > abs a8, a2 > bbsi a8, 31, .L4 > mov.n a10, a2 > call8 foo > .L4: > retw.n > > ;; after (endianness-independent) > test0: > entry sp, 32 > abs a8, a2 > bgez a8, .L1 > mov.n a10, a2 > call8 foo > .L1: > retw.n > test1: > entry sp, 32 > abs a8, a2 > bltz a8, .L4 > mov.n a10, a2 > call8 foo > .L4: > retw.n > > gcc/ChangeLog: > > * config/xtensa/xtensa.md (*btrue_INT_MIN): > Change the branch insn condition to test for a negative number > rather than testing for the MSB. > --- > gcc/config/xtensa/xtensa.md | 17 +++++++---------- > 1 file changed, 7 insertions(+), 10 deletions(-)
Regtested for target=xtensa-linux-uclibc, no new regressions. Committed to master. -- Thanks. -- Max