]> git.ipfire.org Git - thirdparty/gcc.git/commit
xtensa: Make one_cmplsi2 optimizer-friendly
authorTakayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
Sun, 29 May 2022 10:46:16 +0000 (19:46 +0900)
committerMax Filippov <jcmvbkbc@gmail.com>
Thu, 9 Jun 2022 22:07:22 +0000 (15:07 -0700)
commit9777d446e2148ef9a6e9f35db3f4eab99ee8812c
tree80a39ec5301760371b73915a7a4a8a8b8c87be7d
parent2fcc69d8ce4eddf6dea878a5383254d366e1bb14
xtensa: Make one_cmplsi2 optimizer-friendly

In Xtensa ISA, there is no single machine instruction that calculates unary
bitwise negation.  But a few optimizers assume that bitwise negation can be
done by a single insn.

As a result, '((x < 0) ? ~x : x)' cannot be optimized to '(x ^ (x >> 31))'
ever before, for example.

This patch relaxes such limitation, by putting the insn expansion off till
the split pass.

gcc/ChangeLog:

* config/xtensa/xtensa.md (one_cmplsi2):
Rearrange as an insn_and_split pattern.

gcc/testsuite/ChangeLog:

* gcc.target/xtensa/one_cmpl_abs.c: New.
gcc/config/xtensa/xtensa.md
gcc/testsuite/gcc.target/xtensa/one_cmpl_abs.c [new file with mode: 0644]