https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89725
--- Comment #7 from bin cheng <amker at gcc dot gnu.org> --- I am testing below simple fix, it bypass access functions doesn't belong to analyzing loop_nest: diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index e536b463e96..410d44f43e8 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -4272,6 +4272,7 @@ build_classic_dist_vector_1 (struct data_dependence_relation *ddr, { unsigned i; lambda_vector init_v = lambda_vector_new (DDR_NB_LOOPS (ddr)); + struct loop *loop = DDR_LOOP_NEST (ddr)[0]; for (i = 0; i < DDR_NUM_SUBSCRIPTS (ddr); i++) { @@ -4302,6 +4303,15 @@ build_classic_dist_vector_1 (struct data_dependence_relation *ddr, return false; } + /* When data references are collected in a loop while data + dependences are analyzed in loop nest nested in the loop, we + would have more number of access functions than number of + loops. Skip access functions of loops not in the loop nest. + + See PR89725 for more information. */ + if (flow_loop_nested_p (get_loop (cfun, var_a), loop)) + continue; + dist = int_cst_value (SUB_DISTANCE (subscript)); index = index_in_loop_nest (var_a, DDR_LOOP_NEST (ddr)); *index_carry = MIN (index, *index_carry); Plus the assert in index_in_loop_nest.