https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99956
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Sth as simple (and brute-force) as the following fixes this. Somehow SCEV
must already know the "point of failure" though and eventually always
instantiating from loop to loop_nest in steps might be more efficient than
trying all possibilities on failure (or maybe we should do that on failure).
diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc
index f45b9364644..215587a8406 100644
--- a/gcc/gimple-loop-interchange.cc
+++ b/gcc/gimple-loop-interchange.cc
@@ -1320,7 +1320,14 @@ compute_access_stride (class loop *loop_nest, class loop
*loop,
}
tree scev_base = build_fold_addr_expr (ref);
tree scev = analyze_scalar_evolution (loop, scev_base);
- scev = instantiate_scev (loop_preheader_edge (loop_nest), loop, scev);
+ tree orig_scev = scev;
+ scev = instantiate_scev (loop_preheader_edge (loop_nest), loop, orig_scev);
+ while (chrec_contains_undetermined (scev) && loop_nest != loop)
+ {
+ loop_nest = loop_nest->inner;
+ scev = instantiate_scev (loop_preheader_edge (loop_nest),
+ loop, orig_scev);
+ }
if (! chrec_contains_undetermined (scev))
{
tree sl = scev;