public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/115137 - more ptr-vs-ptr compare fixes
Date: Tue, 21 May 2024 11:59:54 +0200 (CEST)	[thread overview]
Message-ID: <20240521095959.38BFF13A21@imap1.dmz-prg2.suse.org> (raw)

The following fixes the omission of const-pool included in NONLOCAL.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	PR tree-optimization/115137
	* tree-ssa-structalias.cc (pt_solution_includes_const_pool): NONLOCAL
	also includes constant pool entries.

	* gcc.dg/torture/pr115137.c: New testcase.
---
 gcc/testsuite/gcc.dg/torture/pr115137.c | 34 +++++++++++++++++++++++++
 gcc/tree-ssa-structalias.cc             |  1 +
 2 files changed, 35 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/torture/pr115137.c

diff --git a/gcc/testsuite/gcc.dg/torture/pr115137.c b/gcc/testsuite/gcc.dg/torture/pr115137.c
new file mode 100644
index 00000000000..9cd8ff93633
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr115137.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+
+struct a {
+  int b;
+} c;
+
+int d;
+long e;
+
+static void f(char *g, char *h, struct a *l) {
+  char a[1024];
+  int j = 0;
+
+  if (d)
+    h = a;
+
+  for (; g < h; g++)
+    if (__builtin_iscntrl(*g))
+      ++j;
+
+  while (l->b < j)
+    ;
+}
+
+int main() {
+  static const struct {
+    char *input;
+  } k[] = {{"somepage.html"}, {""}};
+
+  for (unsigned int i = 0; i < 1; ++i) {
+    e = __builtin_strlen(k[i].input);
+    f(k[i].input, k[i].input + e, &c);
+  }
+}
diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index 61fb3610a17..0e9423a78ec 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -7087,6 +7087,7 @@ bool
 pt_solution_includes_const_pool (struct pt_solution *pt)
 {
   return (pt->const_pool
+	  || pt->nonlocal
 	  || (pt->escaped && (!cfun || cfun->gimple_df->escaped.const_pool))
 	  || (pt->ipa_escaped && ipa_escaped_pt.const_pool));
 }
-- 
2.35.3

                 reply	other threads:[~2024-05-21 10:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240521095959.38BFF13A21@imap1.dmz-prg2.suse.org \
    --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).