public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: "Yangfei (Felix)" <felix.yang@huawei.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	Jiangjiji <jiangjiji@huawei.com>
Subject: Re: [PATCH] Only accept BUILT_IN_NORMAL stringops for interesting_stringop_to_profile_p
Date: Thu, 20 Aug 2015 08:16:00 -0000	[thread overview]
Message-ID: <CAFiYyc12mNc9ZgwhESr2_voBGmMonbgGMJHeoKPbpH-kqd0n2A@mail.gmail.com> (raw)
In-Reply-To: <DA41BE1DDCA941489001C7FBD7A8820E8381E71A@szxema507-mbx.china.huawei.com>

On Thu, Aug 20, 2015 at 5:17 AM, Yangfei (Felix) <felix.yang@huawei.com> wrote:
> Hi,
>
>     As DECL_FUNCTION_CODE is overloaded for builtin functions in different classes, so need to check builtin class before using fcode.
>     Patch posted below.  Bootstrapped on x86_64-suse-linux, OK for trunk?
>     Thanks.

Ugh.  The code in the callers already looks like it could have some
TLC, like instead of

  fndecl = gimple_call_fndecl (stmt);
  if (!fndecl)
    return false;
  fcode = DECL_FUNCTION_CODE (fndecl);
  if (!interesting_stringop_to_profile_p (fndecl, stmt, &size_arg))
    return false;

simply do

  if (!gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
    return false;
  if (!interesting_stringop_to_profile_p (gimple_call_fndecl (stmt), ....))

similar for the other caller.  interesting_stringop_to_profile_p can also
get function-code directly from stmt, removing the redundant first
argument or even do the gimple_call_builtin_p call itself.

Mind reworking the patch accordingly?

Thanks,
Richard.

> Index: gcc/value-prof.c
> ===================================================================
> --- gcc/value-prof.c    (revision 141081)
> +++ gcc/value-prof.c    (working copy)
> @@ -1547,8 +1547,12 @@ gimple_ic_transform (gimple_stmt_iterator *gsi)
>  static bool
>  interesting_stringop_to_profile_p (tree fndecl, gimple call, int *size_arg)
>  {
> -  enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
> +  enum built_in_function fcode;
>
> +  if (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
> +    return false;
> +
> +  fcode = DECL_FUNCTION_CODE (fndecl);
>    if (fcode != BUILT_IN_MEMCPY && fcode != BUILT_IN_MEMPCPY
>        && fcode != BUILT_IN_MEMSET && fcode != BUILT_IN_BZERO)
>      return false;
> Index: gcc/ChangeLog
> ===================================================================
> --- gcc/ChangeLog       (revision 141081)
> +++ gcc/ChangeLog       (working copy)
> @@ -1,3 +1,9 @@
> +2015-08-20  Felix Yang  <felix.yang@huawei.com>
> +           Jiji Jiang  <jiangjiji@huawei.com>
> +
> +       * value-prof.c (interesting_stringop_to_profile_p): Only accept string
> +       operations which belong to the BUILT_IN_NORMAL builtin class.
> +
>  2015-08-18  Segher Boessenkool  <segher@kernel.crashing.org>
>
>         Backport from mainline:

  reply	other threads:[~2015-08-20  8:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-20  4:37 Yangfei (Felix)
2015-08-20  8:16 ` Richard Biener [this message]
2015-08-20  9:37   ` Yangfei (Felix)
2015-08-20 11:25     ` 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=CAFiYyc12mNc9ZgwhESr2_voBGmMonbgGMJHeoKPbpH-kqd0n2A@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=felix.yang@huawei.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jiangjiji@huawei.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).