From: Richard Biener <richard.guenther@gmail.com>
To: Jan Hubicka <hubicka@kam.mff.cuni.cz>,
Jan Hubicka via Gcc-patches <gcc-patches@gcc.gnu.org>,
gcc-patches@gcc.gnu.org
Subject: Re: Fix wrong code in ldist-strlen-1.c
Date: Sat, 16 Oct 2021 17:46:13 +0200 [thread overview]
Message-ID: <23050EBE-D814-4E5D-ACFF-9E58EBEDC893@gmail.com> (raw)
In-Reply-To: <20211016124751.GB52572@kam.mff.cuni.cz>
On October 16, 2021 2:47:51 PM GMT+02:00, Jan Hubicka via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>Hi,
>while updating compute_points_to_sets I missed that the code not only
>sets the nonlocal/escaped flags but also initializes pt. With my
>previous change if uses_global_memory is false pt is not updated
>correctly which may lead to wrong code.
>
>This is fixed by the following patch I comitted to avoid strange
>misoptimizations.
>
>Bootstrapped/regtested x86_64-linux and also tested with LTO.
OK.
Richard.
>Honza
>
>gcc/ChangeLog:
>
> PR tree-optimization/102720
> * tree-ssa-structalias.c (compute_points_to_sets): Fix producing
> of call used and clobbered sets.
>
>diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
>index 6f12a66ee0d..2e6513bb72a 100644
>--- a/gcc/tree-ssa-structalias.c
>+++ b/gcc/tree-ssa-structalias.c
>@@ -7541,17 +7541,18 @@ compute_points_to_sets (void)
> determine_global_memory_access (stmt, NULL,
> &reads_global_memory,
> &uses_global_memory);
>- if (!uses_global_memory)
>- ;
>- else if ((vi = lookup_call_use_vi (stmt)) != NULL)
>+ if ((vi = lookup_call_use_vi (stmt)) != NULL)
> {
> *pt = find_what_var_points_to (cfun->decl, vi);
> /* Escaped (and thus nonlocal) variables are always
> implicitly used by calls. */
> /* ??? ESCAPED can be empty even though NONLOCAL
> always escaped. */
>- pt->nonlocal = uses_global_memory;
>- pt->escaped = uses_global_memory;
>+ if (uses_global_memory)
>+ {
>+ pt->nonlocal = uses_global_memory;
>+ pt->escaped = uses_global_memory;
>+ }
> }
> else if (uses_global_memory)
> {
>@@ -7572,17 +7573,18 @@ compute_points_to_sets (void)
> determine_global_memory_access (stmt, &writes_global_memory,
> NULL, NULL);
>
>- if (!writes_global_memory)
>- ;
>- else if ((vi = lookup_call_clobber_vi (stmt)) != NULL)
>+ if ((vi = lookup_call_clobber_vi (stmt)) != NULL)
> {
> *pt = find_what_var_points_to (cfun->decl, vi);
> /* Escaped (and thus nonlocal) variables are always
> implicitly clobbered by calls. */
> /* ??? ESCAPED can be empty even though NONLOCAL
> always escaped. */
>- pt->nonlocal = writes_global_memory;
>- pt->escaped = writes_global_memory;
>+ if (writes_global_memory)
>+ {
>+ pt->nonlocal = writes_global_memory;
>+ pt->escaped = writes_global_memory;
>+ }
> }
> else if (writes_global_memory)
> {
next prev parent reply other threads:[~2021-10-16 15:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-16 12:47 Jan Hubicka
2021-10-16 15:46 ` Richard Biener [this message]
2021-10-16 15:58 ` H.J. Lu
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=23050EBE-D814-4E5D-ACFF-9E58EBEDC893@gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@kam.mff.cuni.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).