On Mon, 27 Jan 2025, Michael Matz wrote: > Hello, > > On Thu, 23 Jan 2025, Richard Biener wrote: > > > When we get a zero distance vector we still have to check for the > > situation of a common inner loop with zero distance. But we can > > still allow a zero distance for the loop we distribute > > (gcc.dg/tree-ssa/ldist-33.c is such a case). This is because > > zero distances in non-outermost loops are a misrepresentation > > of dependence by dependence analysis. > > I think as long as that is the case your proposed changes makes sense. > But perhaps it's worth a comment to that effect, i.e. that because > dependence analysis is wonky (sometime using zero as unknown) we do these > "strange" tests. At least for the occasional reader it will be > unintuitive why the obvious tests aren't working.
Like this? diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc index 9d9d2ae592b..fc0cd3952d5 100644 --- a/gcc/tree-loop-distribution.cc +++ b/gcc/tree-loop-distribution.cc @@ -2193,7 +2193,9 @@ loop_distribution::pg_add_dependence_edges (struct graph *rdg, int dir, this_dir = -this_dir; } /* When then dependence distance of the innermost common - loop of the DRs is zero we have a conflict. */ + loop of the DRs is zero we have a conflict. This is + due to wonky dependence analysis which sometimes + ends up using a zero distance in place of unknown. */ auto l1 = gimple_bb (DR_STMT (dr1))->loop_father; auto l2 = gimple_bb (DR_STMT (dr2))->loop_father; int idx = index_in_loop_nest (find_common_loop (l1, l2)->num,