rs6000: Optimize cmp on rotated 16bits constant
Hi,
When checking eq/ne with a constant which has only 16bits, it can be
optimized to check the rotated data. By this, the constant building
is optimized.
As the example in PR103743:
For "in == 0x8000000000000000LL", this patch generates:
rotldi 3,3,1 ; cmpldi 0,3,1
instead of:
li 9,-1 ; rldicr 9,9,0,0 ; cmpd 0,3,9
Compare with previous version:
https://gcc.gnu.org/pipermail/gcc-patches/2022-August/600475.html.
This patch refactor the code according to review comments.
e.g. updating function names/comments/code.
This patch pass bootstrap and regtest on ppc64 and ppc64le.
Is it ok for trunk? Thanks for comments!
BR,
Jeff(Jiufu)
PR target/103743
gcc/ChangeLog:
* config/rs6000/rs6000-protos.h (can_be_rotated_to_lowbits): New.
(can_be_rotated_to_positive_16bits): New.
(can_be_rotated_to_negative_15bits): New.
* config/rs6000/rs6000.cc (can_be_rotated_to_lowbits): New definition.
(can_be_rotated_to_positive_16bits): New definition.
(can_be_rotated_to_negative_15bits): New definition.
* config/rs6000/rs6000.md (*rotate_on_cmpdi): New define_insn_and_split.
(eqne): Move earlier.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/pr103743.c: New test.
* gcc.target/powerpc/pr103743_1.c: New test.