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/100934 - properly mark irreducible regions for DOM
Date: Mon, 14 Jun 2021 15:12:04 +0200 (CEST)	[thread overview]
Message-ID: <on797770-qn31-5985-2s27-26p9s8o1pr33@fhfr.qr> (raw)

The jump threading code requires marked irreducible regions for the
purpose of validating jump threading paths but DOM fails to provide
that resulting in mised number of iteration upper bounds clearing.

Bootstrap / regtest running on x86_64-unknown-linux-gnu.

2021-06-14  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/100934
	* tree-ssa-dom.c (pass_dominator::execute): Properly
	mark irreducible regions.

	* gcc.dg/torture/pr100934.c: New testcase.
---
 gcc/testsuite/gcc.dg/torture/pr100934.c | 21 +++++++++++++++++++++
 gcc/tree-ssa-dom.c                      |  3 ++-
 2 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/pr100934.c

diff --git a/gcc/testsuite/gcc.dg/torture/pr100934.c b/gcc/testsuite/gcc.dg/torture/pr100934.c
new file mode 100644
index 00000000000..43b78849895
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr100934.c
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+
+int a, b, c, d, e;
+int main()
+{
+  int f = 0, g = 0;
+  for (; f < 2; f++)
+    {
+      int h, i;
+      for (h = 0; h < 2; h++)
+	{
+	  b = e = g ? a % g : 0;
+	  c = d;
+	  for (i = 0; i < 1; i++)
+	    g = 0;
+	  for (; g < 2; g++)
+	    ;
+	}
+    }
+  return 0;
+}
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 075b1ccb9de..c231e6c8467 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -727,7 +727,8 @@ pass_dominator::execute (function *fun)
      gcc.dg/tree-ssa/pr21417.c can't be threaded if loop preheader is
      missing.  We should improve jump threading in future then
      LOOPS_HAVE_PREHEADERS won't be needed here.  */
-  loop_optimizer_init (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES);
+  loop_optimizer_init (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES
+		       | LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS);
 
   /* We need accurate information regarding back edges in the CFG
      for jump threading; this may include back edges that are not part of
-- 
2.26.2

                 reply	other threads:[~2021-06-14 13:12 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=on797770-qn31-5985-2s27-26p9s8o1pr33@fhfr.qr \
    --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).