From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Improve ptr_derefs_may_alias_p for the case of &STRING_CST
Date: Tue, 26 Jul 2022 10:08:34 +0000 (UTC) [thread overview]
Message-ID: <20220726100834.dfiTaVpbGit4J1kATQA2OyV8EJKRTB1rmEdldkhwopM@z> (raw)
When the first pointer happens to be a pointer to a STRING_CST we
give up too early since the 2nd pointer handling could still end
up with a DECL for example which can disambiguate against a STRING_CST
just fine.
Boostrapped and tested on x86_64-unknown-linux-gnu, pushed.
* tree-ssa-alias.cc (ptr_derefs_may_alias_p): If ptr1
points to a constant continue checking ptr2.
---
gcc/tree-ssa-alias.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
index 390cd875074..b4c65da5718 100644
--- a/gcc/tree-ssa-alias.cc
+++ b/gcc/tree-ssa-alias.cc
@@ -349,7 +349,9 @@ ptr_derefs_may_alias_p (tree ptr1, tree ptr2)
else if (base
&& DECL_P (base))
return ptr_deref_may_alias_decl_p (ptr2, base);
- else
+ /* Try ptr2 when ptr1 points to a constant. */
+ else if (base
+ && !CONSTANT_CLASS_P (base))
return true;
}
if (TREE_CODE (ptr2) == ADDR_EXPR)
--
2.35.3
next reply other threads:[~2022-07-26 10:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-26 10:08 Richard Biener [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-07-26 10:08 Richard Biener
2022-07-26 10:08 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=20220726100834.dfiTaVpbGit4J1kATQA2OyV8EJKRTB1rmEdldkhwopM@z \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
/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).