public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Jason Merrill <jason@redhat.com>
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>, nd <nd@arm.com>
Subject: Re: [PATCH v3] Optimize strchr to strlen
Date: Thu, 29 Sep 2016 08:46:00 -0000	[thread overview]
Message-ID: <CAFiYyc2Np01YMeeKK6vL-R+vgsQJVE5mWX_UapMhfEoB+oN62g@mail.gmail.com> (raw)
In-Reply-To: <CADzB+2mPSK0HkRKi9kZNYF43vThqq0FMHfn3HFU=ELJNpqbtyw@mail.gmail.com>

On Wed, Sep 28, 2016 at 5:45 PM, Jason Merrill <jason@redhat.com> wrote:
> OK.
>
> On Wed, Sep 28, 2016 at 11:43 AM, Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>> Jason Merrill wrote:
>>> I think this broke g++.dg/ext/builtin10.C.
>>
>> That's odd. It appears if you add a fold in gimple-fold.c, it no longer calls the
>> folding code in builtins.c. No idea what the idea behind that is (especially since
>> there are other builtins that appear in both files), but this simple patch fixes it:
>>
>> If strchr can't be folded in gimple-fold.c, break so folding code in builtins.c is
>> also called.
>>
>> OK for commit?

Please move the remaining folding of strchr to gimple-fold.c then.
All of the non-constant "folding" in builtins.c should move there,
constant folding parts should move to fold-const-call.c.

Thanks,
Richard.

>> 2016-09-28  Wilco Dijkstra  <wdijkstr@arm.com>
>>
>>         * gimple-fold.c (gimple_fold_builtin): After failing to fold
>>         strchr, also try the generic folding.
>> --
>> diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
>> index ddf4cf0ae68ef6708377fdb1a2b45575d90da799..b6802e81fd1a7fd0b309cb9aa0f984f7bacb6596 100644
>> --- a/gcc/gimple-fold.c
>> +++ b/gcc/gimple-fold.c
>> @@ -2948,7 +2948,10 @@ gimple_fold_builtin (gimple_stmt_iterator *gsi)
>>      case BUILT_IN_STRNCAT:
>>        return gimple_fold_builtin_strncat (gsi);
>>      case BUILT_IN_STRCHR:
>> -      return gimple_fold_builtin_strchr (gsi);
>> +      if (gimple_fold_builtin_strchr (gsi))
>> +       return true;
>> +      /* Perform additional folding in builtin.c.  */
>> +      break;
>>      case BUILT_IN_FPUTS:
>>        return gimple_fold_builtin_fputs (gsi, gimple_call_arg (stmt, 0),
>>                                         gimple_call_arg (stmt, 1), false);
>>

  reply	other threads:[~2016-09-29  8:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-23 14:18 Wilco Dijkstra
2016-09-23 14:20 ` Oleg Endo
2016-09-27  9:07   ` Richard Biener
2016-09-28 15:21     ` Jason Merrill
2016-09-28 15:46       ` Wilco Dijkstra
2016-09-28 15:48         ` Jason Merrill
2016-09-29  8:46           ` Richard Biener [this message]
2016-09-28 18:02       ` Christophe Lyon
2016-09-29 12:30   ` Oleg Endo

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=CAFiYyc2Np01YMeeKK6vL-R+vgsQJVE5mWX_UapMhfEoB+oN62g@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=nd@arm.com \
    /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).