public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: Andrew Pinski <andrew.pinski@caviumnetworks.com>,
	       Richard Biener <richard.guenther@gmail.com>,
	       Jakub Jelinek <jakub@redhat.com>,
	       "Hurugalawadi,
	Naveen" <Naveen.Hurugalawadi@caviumnetworks.com>,
	       "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: Fold some equal to and not equal to patterns in match.pd
Date: Fri, 24 Jul 2015 07:48:00 -0000	[thread overview]
Message-ID: <55B1D313.6010703@redhat.com> (raw)
In-Reply-To: <20150723163329.GA27818@gate.crashing.org>

On 07/23/2015 10:33 AM, Segher Boessenkool wrote:
> On Thu, Jul 23, 2015 at 10:09:49AM -0600, Jeff Law wrote:
>> It seems to me in these kind of cases that selection of the canonical
>> form should be driven by factors outside of which is better for a
>> particular target.  ie, which is simpler
>
> I agree.  But neither form is simpler here, and we need to have both
> forms in other contexts, so there is no real benefit to canonicalising.


a << N ==/!= 0

Looks like two operations.  A shift and a comparison against zero 
regardless of whether or not N is constant.


a&(-1>>N) ==/!= 0

For a varying N, this has a shift, logical and and comparison against zero.

For a constant N obviously the shift collapses to a constant and we're 
left with two operations again.

So for gimple, I'd prefer to see us using the a << N form.

If we need both forms in other contexts, we ought to be looking to 
eliminate that need :-)

If we go to the RTL level, then it's more complex -- it might depend on 
the constant produced by the -1 >> N operation, whether or not the 
target can shift by more than one bit at a time (H8/300 series is 
limited here for example), whether or not one operation sets condition 
codes in a useful way, potentially allowing the comparison to be 
removed, etc etc.  rtx_costs, even with its limitations is probably the 
way to drive selection of form for the RTL optimizers.


Jeff

  reply	other threads:[~2015-07-24  5:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-21  9:16 Hurugalawadi, Naveen
2015-07-21  9:38 ` pinskia
2015-07-21 10:39   ` Kyrill Tkachov
2015-07-21 10:56     ` pinskia
2015-07-21 11:09       ` Kyrill Tkachov
2015-07-21 15:21       ` Kyrill Tkachov
2015-07-21  9:51 ` Jakub Jelinek
2015-07-21 19:55   ` Richard Biener
2015-07-22  7:09     ` Andrew Pinski
2015-07-22 11:22       ` Richard Biener
2015-07-22 13:50       ` Segher Boessenkool
2015-07-23 17:06       ` Jeff Law
2015-07-23 17:12         ` Segher Boessenkool
2015-07-24  7:48           ` Jeff Law [this message]
2015-07-24  8:01             ` Kai Tietz
2015-07-24  9:31               ` Richard Biener
2015-07-22 11:37 ` Richard Biener

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=55B1D313.6010703@redhat.com \
    --to=law@redhat.com \
    --cc=Naveen.Hurugalawadi@caviumnetworks.com \
    --cc=andrew.pinski@caviumnetworks.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=richard.guenther@gmail.com \
    --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).