From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B16BE3858C50; Tue, 5 Mar 2024 08:21:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B16BE3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709626889; bh=3nzHI0ejmBRvyoCSAR9d3aqRlUgG2E56M4/3N2ptWRQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rgwNX9nyhl9KXo4s7vkZukUNP6ba6trRq0aFGoqIayNRMvuUIh1pvccAOCgZ4BEbC Z6LGalUq+/cjcor+ApqwzxssJ0L1mYCykmmBIdG+q44QN2qOPIKls5jkbmLstYwgkQ ABRnlg/H6Ph8QUrw6xdrG+xyDiiSZlK6Au6tZ4pw= From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113441] [14 Regression] Fail to fold the last element with multiple loop since g:2efe3a7de0107618397264017fb045f237764cc7 Date: Tue, 05 Mar 2024 08:21:26 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113441 --- Comment #43 from rguenther at suse dot de --- On Mon, 4 Mar 2024, rsandifo at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113441 >=20 > --- Comment #41 from Richard Sandiford --- > (In reply to Richard Biener from comment #40) > > So I wonder if we can use "local costing" to decide a gather is always = OK > > compared to the alternative with peeling for gaps. On x86 gather tends > > to be slow compared to open-coding it. > Yeah, on SVE gathers are generally ?enabling? instructions rather than > something to use for their own sake. >=20 > I suppose one problem is that we currently only try to use gathers for > single-element groups. If we make a local decision to use gathers while > keeping that restriction, we could end up using gathers ?unnecessarily? w= hile > still needing to peel for gaps for (say) a two-element group. >=20 > That is, it's only better to use gathers than contiguous loads if by doin= g that > we avoid all need to peel for gaps (and if the cost of peeling for gaps w= as > high enough to justify the cost of using gathers over consecutive loads). Yep. I do want to experiment with a way to have vectorizable_* register multiple variants of vectorization and have ways to stitch together and=20 cost the overall vectorization as a cheaper (and more flexible) way to "iteration". It will to some extent blow up combinations to try but there might be a way to use greedy relaxation techniques to converge to a lowest cost variant. > One of the things on the list to do (once everything is SLP!) is to suppo= rt > loads with gaps directly via predication, so that we never load elements = that > aren't needed. E.g. on SVE, a 64-bit predicate (PTRUE .D) can be used wi= th a > 32-bit load (LD1W .S) to load only even-indexed elements. So a single-el= ement > group with a group size of 2 could be done cheaply with just consecutive = loads, > without peeling for gaps. Yep. Gap handling leaves to be desired (also when no predication is available), I also plan to address some shortcomings in that area early stage1. Note that generally the idea is that gap peeling is very cheap - unless that is the only reason to have an epilogue at all. The exeption might be small round-trip loops but those are best handled with predication where there's no good reason to do peeling for gaps at all.=