public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/108825 - checking ICE with unroll-and-jam
@ 2023-02-20 10:02 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-02-20 10:02 UTC (permalink / raw)
  To: gcc-patches

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-20 10:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-20 10:02 [PATCH] tree-optimization/108825 - checking ICE with unroll-and-jam Richard Biener

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).