* [1/2] Add get_next_strinfo helper function
@ 2017-05-16 8:02 Richard Sandiford
2017-05-31 6:59 ` Richard Sandiford
0 siblings, 1 reply; 3+ messages in thread
From: Richard Sandiford @ 2017-05-16 8:02 UTC (permalink / raw)
To: gcc-patches
This patch just adds a helper function for getting the next strinfo
in a chain, since part 2 adds another place where we do that.
Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install?
Thanks,
Richard
2017-05-16 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* tree-ssa-strlen.c (get_next_strinfo): New function.
(get_stridx_plus_constant): Use it.
(zero_length_string): Likewise.
(adjust_related_strinfos): Likewise.
(adjust_last_stmt): Likewise.
Index: gcc/tree-ssa-strlen.c
===================================================================
--- gcc/tree-ssa-strlen.c 2017-05-15 19:57:18.899053381 +0100
+++ gcc/tree-ssa-strlen.c 2017-05-15 20:50:21.412511763 +0100
@@ -156,6 +156,19 @@ get_strinfo (int idx)
return (*stridx_to_strinfo)[idx];
}
+/* Get the next strinfo in the chain after SI, or null if none. */
+
+static inline strinfo *
+get_next_strinfo (strinfo *si)
+{
+ if (si->next == 0)
+ return NULL;
+ strinfo *nextsi = get_strinfo (si->next);
+ if (nextsi == NULL || nextsi->first != si->first || nextsi->prev != si->idx)
+ return NULL;
+ return nextsi;
+}
+
/* Helper function for get_stridx. */
static int
@@ -665,10 +678,8 @@ get_stridx_plus_constant (strinfo *bases
gcc_checking_assert (compare_tree_int (si->length, off) != -1);
for (chainsi = si; chainsi->next; chainsi = si)
{
- si = get_strinfo (chainsi->next);
+ si = get_next_strinfo (chainsi);
if (si == NULL
- || si->first != chainsi->first
- || si->prev != chainsi->idx
|| si->length == NULL_TREE
|| TREE_CODE (si->length) != INTEGER_CST)
break;
@@ -736,26 +747,18 @@ zero_length_string (tree ptr, strinfo *c
si = verify_related_strinfos (chainsi);
if (si)
{
- chainsi = si;
- for (; chainsi->next; chainsi = si)
+ do
{
- if (chainsi->endptr == NULL_TREE)
+ gcc_assert (si->length || si->stmt);
+ if (si->endptr == NULL_TREE)
{
- chainsi = unshare_strinfo (chainsi);
- chainsi->endptr = ptr;
+ si = unshare_strinfo (si);
+ si->endptr = ptr;
}
- si = get_strinfo (chainsi->next);
- if (si == NULL
- || si->first != chainsi->first
- || si->prev != chainsi->idx)
- break;
- }
- gcc_assert (chainsi->length || chainsi->stmt);
- if (chainsi->endptr == NULL_TREE)
- {
- chainsi = unshare_strinfo (chainsi);
- chainsi->endptr = ptr;
+ chainsi = si;
+ si = get_next_strinfo (si);
}
+ while (si != NULL);
if (chainsi->length && integer_zerop (chainsi->length))
{
if (chainsi->next)
@@ -833,12 +836,8 @@ adjust_related_strinfos (location_t loc,
si->endptr = NULL_TREE;
si->dont_invalidate = true;
}
- if (si->next == 0)
- return;
- nsi = get_strinfo (si->next);
- if (nsi == NULL
- || nsi->first != si->first
- || nsi->prev != si->idx)
+ nsi = get_next_strinfo (si);
+ if (nsi == NULL)
return;
si = nsi;
}
@@ -995,15 +994,9 @@ adjust_last_stmt (strinfo *si, gimple *s
return;
while (firstsi != lastsi)
{
- strinfo *nextsi;
- if (firstsi->next == 0)
- return;
- nextsi = get_strinfo (firstsi->next);
- if (nextsi == NULL
- || nextsi->prev != firstsi->idx
- || nextsi->first != si->first)
+ firstsi = get_next_strinfo (firstsi);
+ if (firstsi == NULL)
return;
- firstsi = nextsi;
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [1/2] Add get_next_strinfo helper function
2017-05-16 8:02 [1/2] Add get_next_strinfo helper function Richard Sandiford
@ 2017-05-31 6:59 ` Richard Sandiford
2017-05-31 7:19 ` Jakub Jelinek
0 siblings, 1 reply; 3+ messages in thread
From: Richard Sandiford @ 2017-05-31 6:59 UTC (permalink / raw)
To: gcc-patches
Ping
Richard Sandiford <richard.sandiford@linaro.org> writes:
> This patch just adds a helper function for getting the next strinfo
> in a chain, since part 2 adds another place where we do that.
>
> Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install?
>
> Thanks,
> Richard
>
>
> 2017-05-16 Richard Sandiford <richard.sandiford@linaro.org>
>
> gcc/
> * tree-ssa-strlen.c (get_next_strinfo): New function.
> (get_stridx_plus_constant): Use it.
> (zero_length_string): Likewise.
> (adjust_related_strinfos): Likewise.
> (adjust_last_stmt): Likewise.
>
> Index: gcc/tree-ssa-strlen.c
> ===================================================================
> --- gcc/tree-ssa-strlen.c 2017-05-15 19:57:18.899053381 +0100
> +++ gcc/tree-ssa-strlen.c 2017-05-15 20:50:21.412511763 +0100
> @@ -156,6 +156,19 @@ get_strinfo (int idx)
> return (*stridx_to_strinfo)[idx];
> }
>
> +/* Get the next strinfo in the chain after SI, or null if none. */
> +
> +static inline strinfo *
> +get_next_strinfo (strinfo *si)
> +{
> + if (si->next == 0)
> + return NULL;
> + strinfo *nextsi = get_strinfo (si->next);
> + if (nextsi == NULL || nextsi->first != si->first || nextsi->prev != si->idx)
> + return NULL;
> + return nextsi;
> +}
> +
> /* Helper function for get_stridx. */
>
> static int
> @@ -665,10 +678,8 @@ get_stridx_plus_constant (strinfo *bases
> gcc_checking_assert (compare_tree_int (si->length, off) != -1);
> for (chainsi = si; chainsi->next; chainsi = si)
> {
> - si = get_strinfo (chainsi->next);
> + si = get_next_strinfo (chainsi);
> if (si == NULL
> - || si->first != chainsi->first
> - || si->prev != chainsi->idx
> || si->length == NULL_TREE
> || TREE_CODE (si->length) != INTEGER_CST)
> break;
> @@ -736,26 +747,18 @@ zero_length_string (tree ptr, strinfo *c
> si = verify_related_strinfos (chainsi);
> if (si)
> {
> - chainsi = si;
> - for (; chainsi->next; chainsi = si)
> + do
> {
> - if (chainsi->endptr == NULL_TREE)
> + gcc_assert (si->length || si->stmt);
> + if (si->endptr == NULL_TREE)
> {
> - chainsi = unshare_strinfo (chainsi);
> - chainsi->endptr = ptr;
> + si = unshare_strinfo (si);
> + si->endptr = ptr;
> }
> - si = get_strinfo (chainsi->next);
> - if (si == NULL
> - || si->first != chainsi->first
> - || si->prev != chainsi->idx)
> - break;
> - }
> - gcc_assert (chainsi->length || chainsi->stmt);
> - if (chainsi->endptr == NULL_TREE)
> - {
> - chainsi = unshare_strinfo (chainsi);
> - chainsi->endptr = ptr;
> + chainsi = si;
> + si = get_next_strinfo (si);
> }
> + while (si != NULL);
> if (chainsi->length && integer_zerop (chainsi->length))
> {
> if (chainsi->next)
> @@ -833,12 +836,8 @@ adjust_related_strinfos (location_t loc,
> si->endptr = NULL_TREE;
> si->dont_invalidate = true;
> }
> - if (si->next == 0)
> - return;
> - nsi = get_strinfo (si->next);
> - if (nsi == NULL
> - || nsi->first != si->first
> - || nsi->prev != si->idx)
> + nsi = get_next_strinfo (si);
> + if (nsi == NULL)
> return;
> si = nsi;
> }
> @@ -995,15 +994,9 @@ adjust_last_stmt (strinfo *si, gimple *s
> return;
> while (firstsi != lastsi)
> {
> - strinfo *nextsi;
> - if (firstsi->next == 0)
> - return;
> - nextsi = get_strinfo (firstsi->next);
> - if (nextsi == NULL
> - || nextsi->prev != firstsi->idx
> - || nextsi->first != si->first)
> + firstsi = get_next_strinfo (firstsi);
> + if (firstsi == NULL)
> return;
> - firstsi = nextsi;
> }
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [1/2] Add get_next_strinfo helper function
2017-05-31 6:59 ` Richard Sandiford
@ 2017-05-31 7:19 ` Jakub Jelinek
0 siblings, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2017-05-31 7:19 UTC (permalink / raw)
To: gcc-patches, richard.sandiford
On Wed, May 31, 2017 at 07:58:54AM +0100, Richard Sandiford wrote:
> Ping
>
> Richard Sandiford <richard.sandiford@linaro.org> writes:
> > This patch just adds a helper function for getting the next strinfo
> > in a chain, since part 2 adds another place where we do that.
> >
> > Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install?
> >
> > Thanks,
> > Richard
> >
> >
> > 2017-05-16 Richard Sandiford <richard.sandiford@linaro.org>
> >
> > gcc/
> > * tree-ssa-strlen.c (get_next_strinfo): New function.
> > (get_stridx_plus_constant): Use it.
> > (zero_length_string): Likewise.
> > (adjust_related_strinfos): Likewise.
> > (adjust_last_stmt): Likewise.
Ok, thanks.
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-31 7:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-16 8:02 [1/2] Add get_next_strinfo helper function Richard Sandiford
2017-05-31 6:59 ` Richard Sandiford
2017-05-31 7:19 ` Jakub Jelinek
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).