public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: [RFA] Reimplement canonicalization of comparison arguments in match.pd
Date: Tue, 02 Jun 2015 22:07:00 -0000	[thread overview]
Message-ID: <556E28B1.7050203@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1505301117330.1938@laptop-mg.saclay.inria.fr>

On 05/30/2015 03:57 AM, Marc Glisse wrote:
> On Fri, 29 May 2015, Jeff Law wrote:
>
>> c-common.c::shorten_compare has code to canonicalize the arguments of
>> a comparison so that the constant is the second argument.  This patch
>> removes the implementation from c-common.c and instead implements it
>> in match.pd.
>>
>> Note the match.pd tries to match the prior behavior of
>> shorten_compare, hence the strange handling of zero.  No justification
>> exists AFAIK for that strange handling in shorten_compare.
>>
>> The match.pd pattern is primarily Kai's -- I just took the 4 patterns
>> he wrote and squashed them into a single pattern to avoid the test
>> duplication.
>>
>> The xfailed testcase is only case I saw across my comparison tests
>> where this change regressed.  Basically shorten-compare had something
>> non-canonical when called.  It was able to canonicalize, then optimize
>> the result.  I just wanted a record of that test in the testsuite.
>> Obviously if we hit our goal of implementing everything from
>> shorten_compare, that test will no longer need to be xfailed :-)
>>
>> Bootstrapped and regression tested on x86-linux-gnu.  OK for the trunk?
>
> I understand doing it in 2 commits to better see what regresses, but I
> don't think we should keep the weirdness in match.pd.
By the weirdness, are you referring to the handling of zero?  I don't 
mind losing that at all.    I'd speculate that Kai was just trying to 
mirror what shorten_compare did to make testing easier.

In fact, that seems like something we ought to test.  If that special 
handling gets ripped out, does anything change and if it does we can 
evaluate the pros/cons of whatever we see.


>
> Does it regress anything if we instead add inside the for loop that
> follows /* -A CMP -B -> B CMP A.  */
>
> (simplify
>   (cmp CONSTANT_CLASS_P@0 @1)
>   (scmp @1 @0))
I'll give it a try.  If we can cleanly integrate this into an existing 
pattern, that works for me.

Jeff

  reply	other threads:[~2015-06-02 22:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-30  5:02 Jeff Law
2015-05-30 15:10 ` Marc Glisse
2015-06-02 22:07   ` Jeff Law [this message]
2015-06-04  5:47   ` Jeff Law
2015-06-01 11:16 ` Richard Biener
2015-06-02 22:54   ` Jeff Law
2015-06-04  4:53   ` Jeff Law

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=556E28B1.7050203@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.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).