[Bug target/103743] PPC: Inefficient equality compare for large 64-bit constants having only 16-bit relevant bits in high part

2023-01-08 Thread guojiufu at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103743

Jiu Fu Guo  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from Jiu Fu Guo  ---
Fixed now.

[Bug target/103743] PPC: Inefficient equality compare for large 64-bit constants having only 16-bit relevant bits in high part

2022-12-19 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103743

--- Comment #7 from CVS Commits  ---
The master branch has been updated by Jiu Fu Guo :

https://gcc.gnu.org/g:1060cd2ad00b5174f4f8ef8ca3d8c283e321ffca

commit r13-4803-g1060cd2ad00b5174f4f8ef8ca3d8c283e321ffca
Author: Jiufu Guo 
Date:   Tue Dec 20 11:43:57 2022 +0800

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 == 0x8000LL", 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.

[Bug target/103743] PPC: Inefficient equality compare for large 64-bit constants having only 16-bit relevant bits in high part

2022-05-15 Thread guojiufu at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103743

--- Comment #6 from Jiu Fu Guo  ---
Drafted a patch:
https://gcc.gnu.org/pipermail/gcc-patches/2022-May/594702.html

[Bug target/103743] PPC: Inefficient equality compare for large 64-bit constants having only 16-bit relevant bits in high part

2022-03-16 Thread guojiufu at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103743

--- Comment #5 from Jiu Fu Guo  ---
It would be also ok for the constant that only has 16bits in the middle:
e.g. 0x09876000ULL, we can rotate the constant to 0x9876.

[Bug target/103743] PPC: Inefficient equality compare for large 64-bit constants having only 16-bit relevant bits in high part

2022-03-15 Thread guojiufu at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103743

Jiu Fu Guo  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |guojiufu at gcc dot 
gnu.org

--- Comment #4 from Jiu Fu Guo  ---
rot(a)==rot(b_)==> a==rot(b')

[Bug target/103743] PPC: Inefficient equality compare for large 64-bit constants having only 16-bit relevant bits in high part

2022-03-14 Thread guojiufu at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103743

Jiu Fu Guo  changed:

   What|Removed |Added

 CC||guojiufu at gcc dot gnu.org

--- Comment #3 from Jiu Fu Guo  ---
For "in == 0x8000LL", it would be also ok with:
rotldi %r9,%r3,16
cmpldi %cr0,%r9,32768

And it would be similar for "in == 0x8000LL" (highest bit and
low48bits are all 1)
rotldi %r9,%r3,16
cmpdi %cr0,%r9,-32768

[Bug target/103743] PPC: Inefficient equality compare for large 64-bit constants having only 16-bit relevant bits in high part

2021-12-16 Thread pthaugen at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103743

--- Comment #2 from pthaugen at gcc dot gnu.org ---
(In reply to Peter Bergner from comment #1)
> Pat, does the patch from Alan you're working to get committed help with this
> test case?

No, it just loads the constant slightly different:

li 9,1
rotldi 9,9,63
cmpd 0,3,9

[Bug target/103743] PPC: Inefficient equality compare for large 64-bit constants having only 16-bit relevant bits in high part

2021-12-16 Thread bergner at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103743

Peter Bergner  changed:

   What|Removed |Added

 CC||pthaugen at gcc dot gnu.org

--- Comment #1 from Peter Bergner  ---
Pat, does the patch from Alan you're working to get committed help with this
test case?

[Bug target/103743] PPC: Inefficient equality compare for large 64-bit constants having only 16-bit relevant bits in high part

2021-12-15 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103743

Andrew Pinski  changed:

   What|Removed |Added

   Severity|normal  |enhancement