From: Richard Biener <richard.guenther@gmail.com>
To: "Martin Liška" <mliska@suse.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 2/3] Fold __builtin_memchr (version 2)
Date: Fri, 07 Oct 2016 11:01:00 -0000 [thread overview]
Message-ID: <CAFiYyc1ifdiNNaQdJjvdORq-5LCNYcwhUkBb4bA7YMZHbo4cLw@mail.gmail.com> (raw)
In-Reply-To: <7c8c5c76-ba33-8fe5-5368-6741d39c8f83@suse.cz>
On Fri, Oct 7, 2016 at 10:41 AM, Martin Liška <mliska@suse.cz> wrote:
> Resending the patch, where I implemented folding in gimple-fold.c
>
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
+/* Fold a call to the str{n}{case}cmp builtin pointed by GSI iterator.
+ FCODE is the name of the builtin. */
wrong comment
+static bool
+gimple_fold_builtin_memchr (gimple_stmt_iterator *gsi)
+ {
+ replace_call_with_value (gsi, build_int_cst (type, 0));
use ptr_type_node (void *) instead of type here and below.
+ HOST_WIDE_INT offset = r - p1;
+ if (compare_tree_int (len, offset) <= 0)
+ {
== 0 can occur in which case we have to return a pointer to the
first char. I think len < offset can't happen with memchr?
+ replace_call_with_value (gsi, build_int_cst (type, 0));
+ return true;
+ }
+ else
+ {
+ tree temp = fold_build_pointer_plus_hwi_loc (loc, arg1, offset);
+ replace_call_with_value (gsi, temp);
That yields valid GIMPLE by chance, I'd prefer if you'd built that to a
stmt and use the replace-with-vops.
+ return true;
+ }
> Ready to be installed?
> Martin
next prev parent reply other threads:[~2016-10-07 11:01 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-17 6:55 [PATCH 0/3] Better folding of 2 string builtin-ins marxin
2016-08-17 6:55 ` [PATCH 3/3] Test folding of strn{case}cmp and memchr marxin
2016-08-17 7:52 ` Martin Liška
2016-10-07 8:42 ` [PATCH 3/3] Test folding of str{n}{case}cmp and memchr (version 2) Martin Liška
2016-10-11 9:39 ` [PATCH] Test folding of str{n}{case}cmp and memchr (version 3) Martin Liška
2016-10-12 8:35 ` Richard Biener
2016-10-12 13:20 ` Martin Liška
2016-10-13 15:27 ` [PATCH] Test folding of str{n}{case}cmp and memchr (simplified version 4) Martin Liška
2016-10-14 11:58 ` Richard Biener
2016-08-17 6:55 ` [PATCH 1/3] Fold BUILT_IN_STRNCASECMP marxin
2016-08-17 7:10 ` Jakub Jelinek
2016-08-17 7:52 ` Martin Liška
2016-10-07 8:39 ` [PATCH 1/3] Fold __builtin_str{n}{case}cmp functions (version 2) Martin Liška
2016-10-07 10:50 ` Richard Biener
2016-10-11 9:26 ` Martin Liška
2016-10-11 10:27 ` Richard Biener
2016-10-11 9:28 ` [PATCH] Add a helper function: create_tmp Martin Liška
2016-10-11 10:30 ` Richard Biener
2016-10-11 10:31 ` Richard Biener
2016-10-12 10:50 ` Martin Liška
2016-10-11 9:28 ` [PATCH] Check \0-termination of string in c_getstr Martin Liška
2016-10-11 10:28 ` Richard Biener
2016-10-12 13:14 ` Martin Liška
2016-10-13 15:24 ` [PATCH] Check \0-termination of string in c_getstr (simplified version) Martin Liška
2016-10-14 9:38 ` Richard Biener
2016-10-14 11:10 ` Martin Liška
2016-10-11 9:34 ` [PATCH] Fold __builtin_str{n}{case}cmp functions (version 3) Martin Liška
2016-10-12 8:30 ` Richard Biener
2016-10-12 13:17 ` Martin Liška
2016-10-13 15:25 ` [PATCH] Fold __builtin_str{n}{case}cmp functions (simplified version 4) Martin Liška
2016-10-14 11:55 ` Richard Biener
2016-08-17 6:55 ` [PATCH 2/3] Smarter folding of __builtin_memchr marxin
2016-08-17 8:41 ` Richard Biener
2016-10-07 8:41 ` [PATCH 2/3] Fold __builtin_memchr (version 2) Martin Liška
2016-10-07 11:01 ` Richard Biener [this message]
2016-10-11 9:38 ` [PATCH] Fold __builtin_memchr (version 3) Martin Liška
2016-10-12 8:34 ` Richard Biener
2016-10-12 8:36 ` Richard Biener
2016-10-12 13:19 ` Martin Liška
2016-10-13 15:26 ` [PATCH] Fold __builtin_memchr (simplified version 4) Martin Liška
2016-10-14 11:57 ` Richard Biener
2016-10-12 13:48 ` [RFC] Possible folding opportunities for string built-ins Martin Liška
2016-10-12 15:55 ` Joseph Myers
2016-10-12 19:45 ` Jim Wilson
2016-10-13 8:38 ` Richard Biener
2016-10-07 11:21 [PATCH 2/3] Fold __builtin_memchr (version 2) Wilco Dijkstra
2016-10-10 10:57 ` Martin Liška
2016-10-10 11:28 ` Wilco Dijkstra
2016-10-10 11:37 ` Martin Liška
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=CAFiYyc1ifdiNNaQdJjvdORq-5LCNYcwhUkBb4bA7YMZHbo4cLw@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=mliska@suse.cz \
/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).