public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jiufu Guo <guojiufu@linux.ibm.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com, linkw@gcc.gnu.org
Subject: Re: [PATCH V7] rs6000: Optimize cmp on rotated 16bits constant
Date: Tue, 20 Dec 2022 12:35:11 +0800	[thread overview]
Message-ID: <7er0wuhev4.fsf@pike.rch.stglabs.ibm.com> (raw)
In-Reply-To: <20221219163355.GO25951@gate.crashing.org> (Segher Boessenkool's message of "Mon, 19 Dec 2022 10:33:55 -0600")


Hi Segher,

Thanks for your review, and helpful comments!

Segher Boessenkool <segher@kernel.crashing.org> writes:

> Hi!
>
> Mostlt nitpicking left:
>
> On Mon, Dec 19, 2022 at 10:06:45PM +0800, Jiufu Guo wrote:
>> 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
>
> Excellent :-)
>
>> 	* 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.
>
> Good names.  Great function comments as well.
>
>> +/* Check if C (as 64bit integer) can be rotated to a constant which constains
>> +   nonzero bits at LOWBITS only.
>
> "at the LOWBITS low bits only".  Well it probably is clear what is
> meant :-)
Update.  Thanks :)
>
>> +   Return true if C can be rotated to such constant.  And *ROT is written to
>> +   the number by which C is rotated.
>> +   Return false otherwise.  */
>
> "If so, *ROT is written" etc.
Great.  Updated.
>
>> +(define_code_iterator eqne [eq ne])
>
> You should say in the changelog that "eqne" was moved.
> "(eqne): Move earlier." is plenty of course.
Sure, thanks! Update.
>
>> +(define_insn_and_split "*rotate_on_cmpdi"
>
>> +  rtx note = find_reg_note (curr_insn, REG_BR_PROB, 0);
>
> Move this much later please, to just before it is used.
Oh, thanks! Update.
>
>> +  /* keep the probability info for the prediction of the branch insn.  */
>
> "Keep", sentences start with a capital.
Update.
>
>> +}
>> +)
>
> These go on one line, as just
> })
Updated.
>
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/powerpc/pr103743.c
>> @@ -0,0 +1,52 @@
>> +/* { dg-options "-O2" } */
>> +/* { dg-do compile { target has_arch_ppc64 } } */
>> +
>> +/* { dg-final { scan-assembler-times {\mcmpldi\M} 10  } } */
>> +/* { dg-final { scan-assembler-times {\mcmpdi\M} 4  } } */
>> +/* { dg-final { scan-assembler-times {\mrotldi\M} 14  } } */
>> +
>
> With so much going on in just one function, I am a bit worried that this
> testcase will easily fail in the future.  We will see.
Thanks for pointing out this. I understand your concern!
I would pay attention to this.

>
> Okay for trunk with those i's dotted.  Thank you!
Updated and committed via r13-4803-g1060cd2ad00b51.


BR,
Jeff (Jiufu)
>
>
> Segher

      reply	other threads:[~2022-12-20  4:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-19 14:06 Jiufu Guo
2022-12-19 16:33 ` Segher Boessenkool
2022-12-20  4:35   ` Jiufu Guo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7er0wuhev4.fsf@pike.rch.stglabs.ibm.com \
    --to=guojiufu@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=linkw@gcc.gnu.org \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).