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/108825 - checking ICE with unroll-and-jam
Date: Mon, 20 Feb 2023 10:02:19 +0000 (UTC)	[thread overview]
Message-ID: <20230220100219.kiXK7aNcmhvJW_tKWrSa9UU_40sKJcJ-bPUkNcVPAdE@z> (raw)

The issue is that unroll-and-jam applies RPO VN on the transformed body but
that leaves the IL in "indetermined" state (it returns a TODO to make it
valid again).  But unroll-and-jam then continues to transform another loop and
in using the tree_unroll_loop helper runs into tree_transform_and_unroll_loop
performing IL checking on the whole function.

While the real fix is to elide all such checking I'm only making the
loop-local LC SSA verifier not perform function-wide SSA verification
at this point.

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

	PR tree-optimization/108825
	* tree-ssa-loop-manip.cc (verify_loop_closed_ssa): For
	loop-local verfication only verify there's no pending SSA
	update.

	* gcc.dg/torture/pr108825.c: New testcase.
---
 gcc/testsuite/gcc.dg/torture/pr108825.c | 20 ++++++++++++++++++++
 gcc/tree-ssa-loop-manip.cc              | 11 ++++++++---
 2 files changed, 28 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/pr108825.c

diff --git a/gcc/testsuite/gcc.dg/torture/pr108825.c b/gcc/testsuite/gcc.dg/torture/pr108825.c
new file mode 100644
index 00000000000..ada2da86054
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr108825.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+
+int safe_mul_func_uint8_t_u_u_ui2, g_231, g_277_1, g_568, func_35___trans_tmp_10;
+int g_81[7];
+extern int g_96[];
+char func_35___trans_tmp_11;
+static inline int safe_add_func_int32_t_s_s(int si1, int si2)
+{ return si1 > 647 - si2 ?: si1; }
+void func_35() {
+  for (; g_277_1; g_277_1 += 1) {
+    g_231 = 0;
+    for (; g_231 <= 6; g_231 += 1) {
+      func_35___trans_tmp_10 =
+          safe_add_func_int32_t_s_s(g_81[g_231], g_568 || g_96[1]);
+      func_35___trans_tmp_11 =
+          func_35___trans_tmp_10 * safe_mul_func_uint8_t_u_u_ui2;
+      g_81[g_231] = func_35___trans_tmp_11;
+    }
+  }
+}
diff --git a/gcc/tree-ssa-loop-manip.cc b/gcc/tree-ssa-loop-manip.cc
index 14fe65f134d..09acc1c94cc 100644
--- a/gcc/tree-ssa-loop-manip.cc
+++ b/gcc/tree-ssa-loop-manip.cc
@@ -681,15 +681,15 @@ verify_loop_closed_ssa (bool verify_ssa_p, class loop *loop)
   if (number_of_loops (cfun) <= 1)
     return;
 
-  if (verify_ssa_p)
-    verify_ssa (false, true);
-
   timevar_push (TV_VERIFY_LOOP_CLOSED);
 
   if (loop == NULL)
     {
       basic_block bb;
 
+      if (verify_ssa_p)
+	verify_ssa (false, true);
+
       FOR_EACH_BB_FN (bb, cfun)
 	if (bb->loop_father && bb->loop_father->num > 0)
 	  check_loop_closed_ssa_bb (bb);
@@ -698,6 +698,11 @@ verify_loop_closed_ssa (bool verify_ssa_p, class loop *loop)
     {
       basic_block *bbs = get_loop_body (loop);
 
+      /* We do not have loop-local SSA verification so just
+	 check there's no update queued.  */
+      if (verify_ssa_p)
+	gcc_assert (!need_ssa_update_p (cfun));
+
       for (unsigned i = 0; i < loop->num_nodes; ++i)
 	check_loop_closed_ssa_bb (bbs[i]);
 
-- 
2.35.3

                 reply	other threads:[~2023-02-20 10:02 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=20230220100219.kiXK7aNcmhvJW_tKWrSa9UU_40sKJcJ-bPUkNcVPAdE@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).