public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Jeff Law <law@redhat.com>
Cc: Marc Glisse <marc.glisse@inria.fr>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RFA] More type narrowing in match.pd V2
Date: Mon, 18 May 2015 09:48:00 -0000	[thread overview]
Message-ID: <CAFiYyc1OLj9Q8DqZc06PKOR23jc8uKmBwa+X_q3m42BSxF=pOg@mail.gmail.com> (raw)
In-Reply-To: <CAFiYyc32_u6VsEjdfqDObSy+GJH70gAd71nvuvHTXEFWkqSTfw@mail.gmail.com>

On Mon, May 18, 2015 at 11:17 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Thu, May 14, 2015 at 4:28 PM, Jeff Law <law@redhat.com> wrote:
>> On 05/14/2015 08:04 AM, Marc Glisse wrote:
>>>
>>> On Fri, 1 May 2015, Jeff Law wrote:
>>>
>>>> Slight refactoring of the condition by using types_match as suggested
>>>> by Richi.  I also applied the new types_match to 2 other patterns in
>>>> match.pd where it seemed clearly appropriate.
>>>
>>>
>>> I would like to propose this small tweak (regtested ok). If we had a
>>> different type for trees and types, this would be overloading the
>>> function. We already do this in a few places, and I find the resulting
>>> shorter code more readable.
>>>
>>> 2015-05-14  Marc Glisse  <marc.glisse@inria.fr>
>>>
>>>      * generic-match-head.c (types_match): Handle non-types.
>>>      * gimple-match-head.c (types_match): Likewise.
>>>      * match.pd: Remove unnecessary TREE_TYPE for types_match.
>>
>> Update the comment for types_match and this is fine.
>
> No - it breaks genmatch autodetection of what trees escape.  It special-cases
> TREE_TYPE ().  See capture_info::walk_c_expr:
>
>   /* Give up for C exprs mentioning captures not inside TREE_TYPE ().  */
>   unsigned p_depth = 0;
>
> so the patch will pessimize GENERIC folding.
>
> Please do not apply.

Hmm, ok - if the functions are only ever used in if()s then it's ok.  You just
have to remember to never use them in (with ...) expressions or transform
results.  Like for example

 (with {
    bool overflow_p;
    wide_int mul = wi::mul (@1, @2, TYPE_SIGN (type), &overflow_p);
   }

is bad because genmatch thinks that @1 and @2 might be used multiple
times in the simplification because they "escape".  It doesn't have
sophisticated
enough analysis to see that mul is only used in a following 'if'.

I suppose we might want to emit warnings from genmatch.c whenever it has
to "give up" for multi-use (thus need to emit save_expr ()) or non-use
(need to use omit_one_operand if TREE_SIDE_EFFECTS, but as it doesn't
know whether it is used in the result we guard the whole pattern with
!TREE_SIDE_EFFECTS).

Richard.

> Richard.
>
>
>> jeff
>>

  reply	other threads:[~2015-05-18  9:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-02  0:36 Jeff Law
2015-05-02 21:18 ` Bernhard Reutner-Fischer
2015-05-04 17:05   ` Jeff Law
2015-05-04  9:02 ` Richard Biener
2015-05-04 19:59   ` H.J. Lu
2015-05-14 14:21 ` Marc Glisse
2015-05-14 14:47   ` Jeff Law
2015-05-18  9:22     ` Richard Biener
2015-05-18  9:48       ` Richard Biener [this message]
2015-05-18 12:40       ` Marc Glisse
2015-05-18 12:53         ` 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='CAFiYyc1OLj9Q8DqZc06PKOR23jc8uKmBwa+X_q3m42BSxF=pOg@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=marc.glisse@inria.fr \
    /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).