https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106019
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to rsand...@gcc.gnu.org from comment #2) > Created attachment 53172 [details] > Candidate patch > > Huh, yeah, surprising this has been present so long. > > Running aff_combination_expand on off2 before the query in > (from dr_may_alias_p): > > aff_tree off1, off2; > poly_widest_int size1, size2; > get_inner_reference_aff (DR_REF (a), &off1, &size1); > get_inner_reference_aff (DR_REF (b), &off2, &size2); > aff_combination_scale (&off1, -1); > aff_combination_add (&off2, &off1); > if (aff_comb_cannot_overlap_p (&off2, size1, size2)) > return false; > > seems to fix it, but I guess that then adds the burden of > maintaining the cache. Since we've already done similar > SSA_NAME expansion for DR_BASE_ADDRESS/DR_OFFSET, perhaps > we should just try to use that instead? The attached patch > does that and fixes the testcase. Ah, that seems to be a good idea. I guess doing that first would make sense. > But maybe there are cases that aff_combination_expand > would handle and this patch wouldn't -- not sure. I suppose we could add statistics to the base-address case added by the patch, the existing DR_REF handling (I suppose this might no longer catch anything with the base-address handling?). Indeed we'd need to maintain a cache for the aff combination expansion if we go that route, but the proposed patch looks like a good improvement (as said, I'd do the check first).