]> gcc.gnu.org Git - gcc.git/commit
rs6000: Optimize cmp on rotated 16bits constant
authorJiufu Guo <guojiufu@linux.ibm.com>
Tue, 20 Dec 2022 03:43:57 +0000 (11:43 +0800)
committerJiufu Guo <guojiufu@linux.ibm.com>
Tue, 20 Dec 2022 03:52:10 +0000 (11:52 +0800)
commit1060cd2ad00b5174f4f8ef8ca3d8c283e321ffca
treedb92c2c3b809205b93a27d0027966cab91fe3881
parentd2ef2327bb357da9d4cff8111e15547441b74c99
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.
gcc/config/rs6000/rs6000-protos.h
gcc/config/rs6000/rs6000.cc
gcc/config/rs6000/rs6000.md
gcc/testsuite/gcc.target/powerpc/pr103743.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/pr103743_1.c [new file with mode: 0644]
This page took 0.068785 seconds and 6 git commands to generate.