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