From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 67DBC385627C; Tue, 21 Jun 2022 06:48:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 67DBC385627C From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106019] Surprising SLP failure on trivial code Date: Tue, 21 Jun 2022 06:48:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rsandifo at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jun 2022 06:48:11 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106019 --- Comment #3 from Richard Biener --- (In reply to rsandifo@gcc.gnu.org from comment #2) > Created attachment 53172 [details] > Candidate patch >=20 > Huh, yeah, surprising this has been present so long. >=20 > Running aff_combination_expand on off2 before the query in > (from dr_may_alias_p): >=20 > 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; >=20 > 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).=